-
8. Useful function call - without include SysIOAPI.DLL
8.1. Warm-boot, Cold-boot and power off
#include <pkfuncs.h>
#include "oemioctl.h"
// Warn boot
KernelIoControl(IOCTL_HAL_REBOOT, NULL, 0, NULL, 0, NULL);
// Cold boot
KernelIoControl(IOCTL_COLD_BOOT, NULL, 0, NULL, 0, NULL);
// Power off
{
DWORD dwExtraInfo=0;
BYTE bScan=0;
keybd_event( VK_OFF, bScan, KEYEVENTF_SILENT, dwExtraInfo );
keybd_event( VK_OFF, bScan, KEYEVENTF_KEYUP, dwExtraInfo );
}
8.2. Get Device ID
In PA500, an unique ID had been burnt into terminal, user can check it by pressing
“Func”+”9”.
The sample code for read device ID as follow,
////////////////////////////////////////////////////////////////
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->dwPlatformIDOffset, pDeviceID->dwPlatformIDBytes);
// Device ID for WinCE version
memcpy((PBYTE)stringBuffer, (PBYTE)pDeviceID + pDeviceID->dwPresetIDOffset, pDeviceID->dwPresetIDBytes);
swprintf(szProductID, _T("%s"), stringBuffer);
// 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.