积极答复者
怎么编程实现ppc关机和重启?

问题
答案
-
//可以模拟用户长按关机键,试试下面代码,在多普达P800 D600等机器上测试可以正常关机。不过在HKC机器上竟然是待机,无语呀~~~
[DllImport ("coredll" )]
public extern static int KernelIoControl (int dwloControlCode , IntPtr lpInBuf , int nlnBufSize , IntPtr lpOutBuf , int nOutBufSize , ref int lpBytesReturned );
[DllImport ("coredll" )]
public extern static void keybd_event (byte bVK , byte bScan , byte dwFlags , byte dwExtraInfo );
public Form1 ()
{
InitializeComponent ();
}
private void button1_Click (object sender , EventArgs e )
{
int IOCTL_HAL_SHUTDOWN = 0x1012000;// 关机
int bytesReturned = 0;
byte VK_OFF = 0xdf;
byte KEYEVENTF_KEYUP = 2;
KernelIoControl (IOCTL_HAL_SHUTDOWN , IntPtr .Zero , 0, IntPtr .Zero , 0, ref bytesReturned );
keybd_event (VK_OFF , 0, 0, 0);
keybd_event (VK_OFF , 0, KEYEVENTF_KEYUP , 0);// 关机
}
2009年7月31日 1:10
全部回复
-
2009年7月23日 5:05
-
Hi,
一般Windows Mobile下通过 ExitWindowsEx实现 (Windows Mobile Version 5.0 SDK )
用法:
BOOL ExitWindowsEx(
UINT uFlags,
DWORD dwReserved
);
参数:
uFlags 代表关闭类型, 关机OR重启
可选值:
EWX_POWEROFF 退出系统并关闭电源 但该值不支持 Windows Mobile 的 Pocket PC.
EWX_REBOOT 退出并且重启系统dwReserved 忽略
返回值:
命令执行成功为非零,执行失败为零。
More information ,you can see:
http://msdn.microsoft.com/en-us/library/ms893047.aspx
Thanks.
Microsoft Online Community Support Please remember to mark the replies as answers if they help and unmark them if they provide no help.2009年7月29日 5:31 -
//可以模拟用户长按关机键,试试下面代码,在多普达P800 D600等机器上测试可以正常关机。不过在HKC机器上竟然是待机,无语呀~~~
[DllImport ("coredll" )]
public extern static int KernelIoControl (int dwloControlCode , IntPtr lpInBuf , int nlnBufSize , IntPtr lpOutBuf , int nOutBufSize , ref int lpBytesReturned );
[DllImport ("coredll" )]
public extern static void keybd_event (byte bVK , byte bScan , byte dwFlags , byte dwExtraInfo );
public Form1 ()
{
InitializeComponent ();
}
private void button1_Click (object sender , EventArgs e )
{
int IOCTL_HAL_SHUTDOWN = 0x1012000;// 关机
int bytesReturned = 0;
byte VK_OFF = 0xdf;
byte KEYEVENTF_KEYUP = 2;
KernelIoControl (IOCTL_HAL_SHUTDOWN , IntPtr .Zero , 0, IntPtr .Zero , 0, ref bytesReturned );
keybd_event (VK_OFF , 0, 0, 0);
keybd_event (VK_OFF , 0, KEYEVENTF_KEYUP , 0);// 关机
}
2009年7月31日 1:10