作者sparc (......)
看板C_Sharp
标题[问题] windows reboot的程式码
时间Mon Jun 16 10:13:09 2008
我正在撰写一个定时reboot的程式
这是我在Google上看到可以用的程式码:
public class API
{
[DllImport("User32.dll")]
public static extern int ExitWindowsEx(
uint uFlags, // shutdown operation
uint dwReason // shutdown reason
);
public enum ExitWindowsEx_uFlags : uint
{
EWX_LOGOFF = 0x0000,
EWX_POWEROFF = 0x0008,
EWX_REBOOT = 0x0002,
EWX_SHUTDOWN = 0x0001
}
public enum ExitWindowsEx_dwReason : uint
{
EWX_FORCE = 0x0004,
FORCEIFHUNG = 0x0010
}
}
执行的部分是:
API.ExitWindowsEx((uint)API.ExitWindowsEx_uFlags.EWX_REBOOT,
(uint)API.ExitWindowsEx_dwReason.FORCEIFHUNG);
可是很奇怪的
这段程式码却没有动作
但如果执行的是LOGOFF 却又可以正常执行
请问一下 这段程式码是有哪边出错吗?
我使用的作业系统是vista会有影响吗?
谢谢
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 118.231.34.223