Skip to content

Latest commit

 

History

History
54 lines (38 loc) · 1.19 KB

File metadata and controls

54 lines (38 loc) · 1.19 KB

Home

Closing Windows

Before you begin:

Similar examples:


Code:

#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  

Listed functions:

ExitWindows
ExitWindowsEx
GetLastError

Comment:

To shut down the local computer, the calling thread must have the SE_SHUTDOWN_NAME privilege.