N
NET CF Questions
We're looking for a sample code for getting a Device Unique ID
(Product ID) in VB.
VB, VS 2005, .Net cf 2.0 sp2
The one we have from the manufacturer is in C++
////////////////////////////////////////////////////////////////
HWND hDeviceId = GetDlgItem(hWnd, IDC_DEVICEID);
PDEVICE_ID pDeviceID = NULL;
TCHAR outBuf[512], szProductID[100], stringBuffer[100];
BYTE szBuff[255];
DWORD bytesReturned;
char platformID[64];
pDeviceID = (PDEVICE_ID)outBuf;
pDeviceID->dwSize = sizeof(outBuf);
if (KernelIoControl(IOCTL_HAL_GET_DEVICEID, NULL, 0, outBuf,
sizeof(outBuf), &bytesReturned))
{
// Platform ID
memcpy((PBYTE)platformID, (PBYTE)pDeviceID + pDeviceID-
memcpy((PBYTE)stringBuffer, (PBYTE)pDeviceID + pDeviceID-
// Device ID for Mobile version
memcpy((PBYTE) szBuff, (PBYTE)pDeviceID + pDeviceID->dwPresetIDOffset,
pDeviceID->dwPresetIDBytes);
swprintf(szProductID, TEXT("%X%X%X%X%X%X%X%X"),
szBuff [0], szBuff [1], szBuff [2], szBuff [3], szBuff [4], szBuff
[5], szBuff [6], szBuff [7]);
}
/////////////////////////////////////////////////////////
The code will have platformID holds Platform ID, and deviceID holds
Device ID.
(Product ID) in VB.
VB, VS 2005, .Net cf 2.0 sp2
The one we have from the manufacturer is in C++
////////////////////////////////////////////////////////////////
HWND hDeviceId = GetDlgItem(hWnd, IDC_DEVICEID);
PDEVICE_ID pDeviceID = NULL;
TCHAR outBuf[512], szProductID[100], stringBuffer[100];
BYTE szBuff[255];
DWORD bytesReturned;
char platformID[64];
pDeviceID = (PDEVICE_ID)outBuf;
pDeviceID->dwSize = sizeof(outBuf);
if (KernelIoControl(IOCTL_HAL_GET_DEVICEID, NULL, 0, outBuf,
sizeof(outBuf), &bytesReturned))
{
// Platform ID
memcpy((PBYTE)platformID, (PBYTE)pDeviceID + pDeviceID-
// Device ID for WinCE versiondwPlatformIDOffset, pDeviceID->dwPlatformIDBytes);
memcpy((PBYTE)stringBuffer, (PBYTE)pDeviceID + pDeviceID-
swprintf(szProductID, _T("%s"), stringBuffer);dwPresetIDOffset, pDeviceID->dwPresetIDBytes);
// Device ID for Mobile version
memcpy((PBYTE) szBuff, (PBYTE)pDeviceID + pDeviceID->dwPresetIDOffset,
pDeviceID->dwPresetIDBytes);
swprintf(szProductID, TEXT("%X%X%X%X%X%X%X%X"),
szBuff [0], szBuff [1], szBuff [2], szBuff [3], szBuff [4], szBuff
[5], szBuff [6], szBuff [7]);
}
/////////////////////////////////////////////////////////
The code will have platformID holds Platform ID, and deviceID holds
Device ID.