我已使用以下代码关闭系统但它将执行注销窗口
Private Const EWX_LogOff = 0
Private Const EWX_SHUTDOWN = 1
Private Const EWX_REBOOT = 2
Private Const EWX_FORCE = 4
Public Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Public Sub ShutDownComputer()
Call ExitWindowsEx(EWX_FORCE, &HFFFFFFFF)
End Sub
答案 0 :(得分:2)
试试这个
Private Const EWX_POWEROFF = 8
Call ExitWindowsEx(EWX_POWEROFF, &HFFFFFFFF)
此链接也可以帮助您
Why simply calling ExitWindowsEx won’t Shutdown/Restart the Computer
答案 1 :(得分:1)
尝试将SHUTDOWN与FORCE结合使用。
答案 2 :(得分:0)
除了Eugene所说的,最好使用pinvoke的声明:
Declare Function ExitWindowsEx Lib "user32" (ByVal dwOptions As Int32, ByVal dwReserved As Int32) As Int32
声明为两个四字节整数的参数(作为dll中的ExitWindowsEx函数)。