借用楼主这块宝地,想请问下,你获取到了序列号,有没有获取过MANUFACTURERID?结构体typedef struct _STORAGE_IDENTIFICATION {
DWORD dwSize;
DWORD dwFlags;
DWORD dwManufactureIDOffset;
DWORD dwSerialNumOffset;
} STORAGE_IDENTIFICATION, *PSTORAGE_IDENTIFICATION;
这里面有个dwFlags,
dwFlags
Provides information about the manufacturer identifier and serial number. Flag Description
MANUFACTURERID_INVALID The identifier for the manufacturer is not valid.
SERIALNUM_INVALID The serial number is not valid.
这里是不是表示有的卡只有一种ID,有的卡两个都有呢?如果两个都有的话,那他的偏移量会不会有重合的现象, 我得到的是这样的 MANUFACTURERID:02AE1A378E, SERIALNUM: AE1A378E,换了几个卡感觉序列号始终是比出厂标示少俩字符,一看就知道偏移量造成两个标示有重合。
是不是我做错了,要怎么搞?
以下是获取函数
void CSystemInfoDlg::dumpStorageId(CString szDisk,CString &strmanu, CString &strcardid)
{
HANDLE hDsk=NULL;
hDsk = ::CreateFile(szDisk, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
byte buf[sizeof(STORAGE_IDENTIFICATION)+256];
STORAGE_IDENTIFICATION *si= (STORAGE_IDENTIFICATION *)buf;
si->dwSize=sizeof(STORAGE_IDENTIFICATION)+256;
DWORD nReturned;
if (!DeviceIoControl(hDsk, IOCTL_DISK_GET_STORAGEID, NULL, 0,buf, sizeof(STORAGE_IDENTIFICATION)+256, &nReturned, NULL))
{
return ;
}
TCHAR bufxx[100],bufyy[100];
wsprintf(bufxx,L"%hs", &buf[si->dwManufactureIDOffset]);
wsprintf(bufyy,L"%hs", &buf[si->dwSerialNumOffset]);
strmanu =bufxx;
strcardid =bufyy;
}