我正在撰寫一個定時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