1. Obtain the device ID.
# Include
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
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 ("");
}
}
Note: Windows Mobile 5.0 has added a dedicated API to complete this task. It can be used for devices earlier than 2003.
This method. Whether this method can obtain the channel Id also depends on whether the hardware manufacturer has implemented the change method. Because
Smartphone provides 2-tie security, so this method may fail to be called if no certificate is authorized.
2. Obtain device information
Tchar wszmachinename [128];
Systemparametersinfo (spi_getoeminfo, sizeof (wszmachinename ),
& Wszmachinename, 0 );
Obtain device OEM information.
Tchar wszversion [256];
Systemparametersinfo (spi_getplatformtype, sizeof (wszversion ),
& Wszversion, 0 );
Obtain the platform information.
3 create guid
cstring createguid ()
{< br> tchar wguid [37];
systemtime completed IME;
filetime;
// construct guid
getsystemtime (& systime);
systemtimetofiletime (& systime, & filetime);
DWORD tick = gettickcount ();
DWORD highword = filetime. dwhighdatetime + 0x146bf4;
// convert guid to a string
wsprintf (wguid, text ("% 08.8x-% 04.4x-% 04.4x-% 04.4x-% 04.4x % 04.4x % 04.4x"),
filetime. dwlowdatetime,
loword (highword),
hiword (highword | 0x10000000),
loword (RAND (),
hiword (tick ),
loword (tick),
loword (RAND ();
return cstring (wguid);
}