|
extern "C" __declspec(dllimport)
BOOL KernelIoControl(
DWORD dwIoControlCode, LPVOID lpInBuf, DWORD nInBufSize,
LPVOID lpOutBuf, DWORD nOutBufSize, LPDWORD lpBytesReturned
);
#define IOCTL_HAL_GET_DEVICEID CTL_CODE(FILE_DEVICE_HAL, 21, METHOD_BUFFERED, FILE_ANY_ACCESS)
CString GetSerialNumberFromKernelIoControl()
{
DWORD dwOutBytes;
const int nBuffSize = 4096;
byte arrOutBuff[nBuffSize];
BOOL bRes = ::KernelIoControl(IOCTL_HAL_GET_DEVICEID,
0, 0, arrOutBuff, nBuffSize, &dwOutBytes);
if (bRes) {
CString strDeviceInfo;
for (unsigned int i = 0; i <dwOutBytes; i++) {
CString strNextChar;
strNextChar.Format(TEXT("%02X"), arrOutBuff);
strDeviceInfo += strNextChar;
}
CString strDeviceId =
strDeviceInfo.Mid(40,2) +
strDeviceInfo.Mid(45,9) +
strDeviceInfo.Mid(70,6);
return strDeviceId;
} else {
return _T("");
}
}
我在网上看到这段代码,但是获取的号码是UUID,并未包含序列号。。。
请高手指点,我的设备是HP ipaq2000系列,我用VC2005。
|
|