Maybe You want to use a DLL-Function :
DLL32 FUNCTION ExitWindow;
( dwReserved AS LONG, ;
uReturnCode AS LONG ) ;
AS LONG PASCAL;
FROM "ExitWindows" LIB "USER32"
and
DLL32 FUNCTION ExitWindEx;
( uFlags AS LONG, ;
dwReserved AS LONG ) ;
AS LONG PASCAL;
FROM "ExitWindowsEx" LIB "USER32"
// uFlags-defines :
#define EWX_LOGOFF 0
#define EWX_SHUTDOWN 1
#define EWX_REBOOT 2
#define EWX_POWEROFF 8
#define EWX_RESTARTAPPS 40
// plus AT MOST ONE of the following two:
#define EWX_FORCE 4
#define EWX_FORCEIFHUNG 10
Value Meaning :
EWX_LOGOFF
0
Shuts down all processes running in the logon session of the process that called the ExitWindowsEx function. Then it logs the user off.
This flag can be used only by processes running in an interactive user's logon session.
EWX_POWEROFF 8
Shuts down the system and turns off the power. The system must support the power-off feature.
The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Remarks section.
EWX_REBOOT 2
Shuts down the system and then restarts the system.
The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Remarks section.
EWX_RESTARTAPPS 40
Shuts down the system and then restarts it, as well as any applications that have been registered for restart using the RegisterApplicationRestart function. These application receive the WM_QUERYENDSESSION message with lParam set to the ENDSESSION_CLOSEAPP value. For more information, see Guidelines for Applications.
EWX_SHUTDOWN 1
Shuts down the system to a point at which it is safe to turn off the power. All file buffers have been flushed to disk, and all running processes have stopped.
The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Remarks section.
Specifying this flag will not turn off the power even if the system supports the power-off feature. You must specify EWX_POWEROFF to do this.
Windows XP with SP1: If the system supports the power-off feature, specifying this flag turns off the power.
This parameter can optionally include one of the following values.
Value Meaning
EWX_FORCE 4
This flag has no effect if terminal services is enabled. Otherwise, the system does not send the WM_QUERYENDSESSION message. This can cause applications to lose data. Therefore, you should only use this flag in an emergency.
EWX_FORCEIFHUNG 10
Forces processes to terminate if they do not respond to the WM_QUERYENDSESSION or WM_ENDSESSION message within the timeout interval.
Best Regards
Uwe