日期:2009-05-26  浏览次数:20400 次

用API函数ExitWindowsEx可以实现强制关机,即便是您的应用程序尚未保存文件

Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long

Const EWX_SHUTDOWN = 1

Const EWX_LOGOFF = 0

Const EWX_REBOOT = 2

Const EWX_FORCE = 4

Private Sub Command1_Click()

Dim a

a = ExitWindowsEx(EWX_LOGOFF or EWX_FORCE or EWX_SHUTDOWN, 0)

End Sub

如果将

a = ExitWindowsEx(EWX_LOGOFF or EWX_FORCE or EWX_SHUTDOWN, 0)

改换为

a = ExitWindowsEx(EWX_LOGOFF or EWX_REBOOT, 0)

即可实现强制重启计算机