关机有好几种方式,下面给你来个代码,让你了解一下。
Option Explicit
Private Declare Function ExitWindowsEx Lib "user32" (ByVal dwOptions As Long, ByVal dwReserved As Long) As Long
Private Const EWX_LOGOFF As Long = 0
Private Const EWX_SHUTDOWN As Long = 1
Private Const EWX_REBOOT As Long = 2
Private Const EWX_FORCE As Long = 4
Private Sub Form_Load()
Rem 关机代码
'ExitWindowsEx (EWX_SHUTDOWN Or EWX_FORCE), &HFFFF '强制关机
'ExitWindowsEx (EWX_SHUTDOWN), &HFFFF '关机
Rem 注销代码
'ExitWindowsEx (EWX_LOGOFF Or EWX_FORCE), &HFFFF '强制注销
'ExitWindowsEx (EWX_LOGOFF), &HFFFF '注销
Rem 重启代码
'ExitWindowsEx (EWX_REBOOT Or EWX_FORCE), &HFFFF '强制重启
'ExitWindowsEx (EWX_REBOOT), &HFFFF '重启
End Sub
[此贴子已经被作者于2023-7-29 11:29编辑过]