|
主要是使用KernelIOControl这个函数 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(""); } }
|