my code:Const EWX_LOGOFF = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
Const EWX_FORCE = 4
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Private Sub Form_Load()
msg = MsgBox("This program is going to reboot your computer. Press OK to continue or Cancel to stop.", vbCritical + vbOKCancel + 256, App.Title)
If msg = vbCancel Then End
'reboot the computer
ret& = ExitWindowsEx(EWX_FORCE Or EWX_REBOOT, 0)
Unload Me
End Sub
what is SE_SHUTDOWN_NAME privilege? blur~
Check out the sample code there:
http://www.vbaccelerator.com/home/VB/Tips/How_to_Shutdown_the_System_in_Windows_9x_and_NT/article.asp
Note that there are a lot other stuff in the sample code. But what you should pay attention to is the part there the current process's privilege tokens are checked, and adjusted, in order to enable the process to shutdown the OS.
Note that there are a lot other stuff in the sample code. But what you should pay attention to is the part there the current process's privilege tokens are checked, and adjusted, in order to enable the process to shutdown the OS.
