ICD3 Target Device ID (00000000)
rnYou can use platform invoke to get the device ID, also known as the serial number, of a Pocket PC. This QuickStart displays the ID in a MessageBox when the application runs. The following is an example of a device ID for a Pocket PC:rnrn8E0000E5-8B82-A17B-0038-0050BF1977E0rnKernelIoControl functionrnrnYou can get the device ID by calling the native Windows CE .NET KernelIoControl function, which has the following parameters:rnrnParameter Bits Win32 Type Managed Type Typical Value rndwIoControlCode 32 DWORD Int32 IOCTL_HAL_GET_DEVICEID rnlpInBuf 32 LPVOID IntPtr IntPtr.Zero (no input data required) rnnInBufSize 32 DWORD Int32 0 (no input data required) rnlpOutBuf 32 DEVICE_ID* byte byte (20 bytes is the size of the DEVICE_ID structure) rnnOutBufSize 32 DWORD Int32 20 rnlpBytesReturned 32 LPDWORD ref Int32 0 rnrnThe lpOutBuf parameter has the following structure:rnrnrn rnstruct DEVICE_IDrnrn Int32 dwSize;rn Int32 dwPresetIDOffset;rn Int32 dwPresetIDBytes;rn Int32 dwPlatformIDOffset;rn Int32 dwPlatformIDBytes;rnrn rnrnReturn values and error handlingrnrnThe KernelIoControl function returns true if the device ID was copied to the output buffer; otherwise, it returns false. If KernelIoControl fails, call the managed Marshal.GetLastWin32Error method to get the Win32 error code. The error code is likely to be either of the following:rnrnERROR_NOT_SUPPORTED - Indicates that the device does not implement the IOCTL_HAL_GET_DEVICEID control code.rnERROR_INSUFFICIENT_BUFFER - Indicates that the output buffer was not large enough to hold the device ID. The required number of bytes, specified by dwSize in the DEVICE_ID structure, is returned in the first four bytes of the output buffer. If this error occurs, reallocate the output buffer to the size specified by dwSize and call KernelIoControl again.