读取SATA硬盘序列号的方法?
本帖最后由 VisualEleven 于 2012-10-10 07:32:12 编辑
各位大侠,VC环境下要去取SATA硬盘序列号与IDE硬盘序列号的方法一样吗?
我用网上的DeviceIoControl这个函数写的,
char sFilePath[64]={0};
sprintf(sFilePath,"\\\\.\\PHYSICALDRIVE%d",driver);//modify by lonkil 2008-07-13
HANDLE hFile = INVALID_HANDLE_VALUE;
hFile = ::CreateFile(sFilePath,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING,
0, NULL);
if (hFile == INVALID_HANDLE_VALUE) return -1;
DWORD dwBytesReturned;
GETVERSIONINPARAMS gvopVersionParams;
DeviceIoControl(hFile,
SMART_GET_VERSION,
NULL,
0,
&gvopVersionParams,
sizeof(gvopVersionParams),
&dwBytesReturned, NULL);
if(gvopVersionParams.bIDEDeviceMap <= 0) return -2;
// IDE