如何编程实现系统正常关机
发布网友
发布时间:2023-01-27 22:00
我来回答
共1个回答
热心网友
时间:2024-12-14 20:15
'VB关机
'GhostE @ [hi.baidu.com/aa64201205]
'没文化 代码垃圾哈
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Private Const EWX_LOGOFF = 0 '退出(注销)
Private Const EWX_SHUTDOWN = 1 '关机
Private Const EWX_REBOOT = 2 '重启动
Private Const EWX_FORCE = 4 '强制关机
Private Declare Function adjp Lib "ntdll" Alias "RtlAdjustPrivilege" (ByVal p As Long, n As Long, t As Long, o As Long) As Long
Private Sub Shutdown()
adjp 19, 1, 0, 0
If MsgBox("Are you sure shutdown now?", vbQuestion + vbYesNo, "Question") = vbYes Then _
ExitWindowsEx EWX_SHUTDOWN, 0
End Sub