如何在程序中关闭、重起和硬起动WCE、PPC、SP

 

关闭(suspend)

方法1:
//虚拟关机键
::keybd_event(VK_OFF, 0, 0, 0);
::keybd_event(VK_OFF, 0, KEYEVENTF_KEYUP, 0);

方法2:
//调用未公开函数PowerOffSystem()
extern "C" __declspec(dllimport) void PowerOffSystem();


重起(soft reset)
//Soft reset the device
#include  〈winioctl.h〉

#define IOCTL_HAL_REBOOT CTL_CODE(FILE_DEVICE_HAL, 15, METHOD_BUFFERED, FILE_ANY_ACCESS)

extern "C" __declspec(dllimport) BOOL KernelIoControl(
 DWORD dwIoControlCode,
 LPVOID lpInBuf,
 DWORD nInBufSize,
 LPVOID lpOutBuf,
 DWORD nOutBufSize,
 LPDWORD lpBytesReturned);

BOOL ResetDevice()
{
 return KernelIoControl(IOCTL_HAL_REBOOT, NULL, 0, NULL, 0, NULL);
}

 

硬起动(hard reset)

//注意!!!使用此段代码会将您的Pocket PC的用户数据全部清空,
//请勿非法使用,用者后果自负.

#include  〈winioctl.h〉

#define IOCTL_HAL_REBOOT CTL_CODE(FILE_DEVICE_HAL, 15, METHOD_BUFFERED, FILE_ANY_ACCESS)

extern "C" __declspec(dllimport)void SetCleanRebootFlag(void);

extern "C" __declspec(dllimport) BOOL KernelIoControl(
 DWORD dwIoControlCode,
 LPVOID lpInBuf,
 DWORD nInBufSize,
 LPVOID lpOutBuf,
 DWORD nOutBufSize,
 LPDWORD lpBytesReturned);

BOOL HardResetDevice()
{
 SetCleanRebootFlag();
 return KernelIoControl(IOCTL_HAL_REBOOT, NULL, 0, NULL, 0, NULL);
}

 

你可能感兴趣的:(如何在程序中关闭、重起和硬起动WCE、PPC、SP)