#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 ExitWindowsEx IN user32; INTEGER uFlags, INTEGER dwReserved * logoff -- change user * = ExitWindowsEx (EWX_LOGOFF, 0) * reboot = ExitWindowsEx (EWX_REBOOT, 0)For Windows NT try this code:
DECLARE INTEGER GetLastError IN kernel32 DECLARE SHORT InitiateSystemShutdown IN advapi32; STRING lpMachineName,; STRING lpMessage,; INTEGER dwTimeout,; SHORT bForceAppsClosed,; SHORT bRebootAfterShutdown IF InitiateSystemShutdown ("", "User time is out", 10, 0, 1) <> 1 * Common reasons for failure include an invalid * or inaccessible computer name or insufficient privilege. * 5 = ERROR_ACCESS_DENIED * 120 = ERROR_CALL_NOT_IMPLEMENTED -- not supported in Win9* ? "Error code:", GetLastError() ENDIFThere is another API function allowing to restart Windows:
DECLARE INTEGER RestartDialog IN shell32; INTEGER hParent, STRING pszPrompt, LONG dwFlagsIf you want to suspend or hibernate your system, here is an API function for this too:
DECLARE INTEGER SetSuspendState IN Powrprof; INTEGER Hibernate, INTEGER ForceCritical,; INTEGER DisableWakeEvent