如何用API函数控制关闭计算机?
API函数 !请注意你WINDOWS的版本*API函数声明Declare Function ExitWindows Lib "User" (ByVal dwReturnCode As Long, ByVal wReserved As Integer) As Integer注释:执行Dim DUMMY DUMMY=ExitWindows(0,0) 强制关闭计算机:用API函数ExitWindowsEx可以实现强制关机,即便是您的应用程序尚未保存文件。Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As LongConst EWX_SHUTDOWN = 1Const EWX_LOGOFF = 0Const EWX_REBOOT = 2 Const EWX_FORCE = 4Private Sub Command1_Click()Dim aa = 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)即可实现强制重启计算机!
页:
[1]