Public Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
在按鈕事件中用如下代碼可關機:
Private Sub Command1_Click()
ExitWindowsEx 1, 0
End Sub
在按鈕事件中用如下代碼可重啟:
Private Sub Command1_Click()
ExitWindowsEx 2, 0
End Sub
上述代碼在WIN9X系統未見問題,在WIN2000不能實現。WINXP有些版本無問題。
以下是“逍遙忘我”網友的答復:
Shell "shutdown.exe -s -f -t 0",vbhide