Similar examples:
- How to initiate System shutdown (WinNT only)
- Restarting Windows
- Enabling the SE_SHUTDOWN_NAME privilege for the application
#DEFINE EWX_LOGOFF 0
#DEFINE EWX_SHUTDOWN 1
#DEFINE EWX_REBOOT 2
#DEFINE EWX_FORCE 4
#DEFINE EWX_POWEROFF 8
#DEFINE EWX_FORCEIFHUNG 16
DECLARE INTEGER GetLastError IN kernel32
DECLARE INTEGER ExitWindows IN user32;
INTEGER dwReserved, INTEGER uReturnCode
DECLARE INTEGER ExitWindowsEx IN user32;
INTEGER uFlags, INTEGER dwReserved
* logoff -- change user
* = ExitWindowsEx(EWX_LOGOFF, 0)
* reboot
nResult = ExitWindowsEx(EWX_REBOOT, 0)
IF nResult=0
* 1314=ERROR_PRIVILEGE_NOT_HELD
? "ExitWindowsEx call failed:", GetLastError()
ENDIF ExitWindows
ExitWindowsEx
GetLastError
To shut down the local computer, the calling thread must have the SE_SHUTDOWN_NAME privilege.
Home