See also:
- How to initiate System shutdown (WinNT only)
- Closing 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
DO decl
LOCAL lcMessage
lcMessage = Conv2Unicode("Using the RestartDialog function: "+;
Chr(13)+Chr(13))
= RestartDialog(GetActiveWindow(), lcMessage,;
EWX_SHUTDOWN)
FUNCTION Conv2Unicode (lcString)
LOCAL lcResult, ii
lcResult=""
FOR ii=1 To Len(lcString)
lcResult = lcResult + SUBSTR(lcString, ii,1) + Chr(0)
ENDFOR
RETURN lcResult+Chr(0)
PROCEDURE decl
DECLARE INTEGER GetActiveWindow IN user32
DECLARE INTEGER RestartDialog IN shell32;
INTEGER hParent, STRING pszPrompt, LONG dwFlags
To shut down the local computer, the calling thread must have the SE_SHUTDOWN_NAME privilege.