wince软件实现重启待机

可以通过如下代码实现:
    重启:KernelIoControl(IOCTL_HAL_REBOOT, NULL, 0, NULL, 0, NULL);
    关机:SetSystemPowerState(NULL, POWER_STATE_OFF, POWER_FORCE);
    待机:GwesPowerOffSystem();

    具体的效果还要看系统底层的实现情况。


关闭(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);
}



另外wince 5.01 以后版本提供了重启的函数:ExitWindowsEx


This function shuts down the system.
BOOL ExitWindowsEx(
   UINT uFlags,
   DWORD dwReserved
);
Parameters
uFlags 
[in] Specifies the type of shutdown. This parameter must be one of the following values. 
Value Description 
EWX_POWEROFF  Shuts down the system and turns off the power. 
           Note   This flag is not supported on a Windows Mobile-based Pocket PC. 
EWX_REBOOT  Shuts down the system and reboots. 


dwReserved 
[in] Reserved; this parameter is ignored. 
Return Values
If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. 


Remarks
The ExitWindowsEx function returns as soon as it has initiated the shutdown. The shutdown then proceeds asynchronously. 


Requirements
Pocket PC: Windows Mobile 5.0 and later.
Smartphone: Windows Mobile 5.0 and later.
OS Versions: Windows CE 5.01 and later.
Header: Aygshell.h.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值