Hello!
I want to log off when the user exits FiveWin application.
Does anyone know how to do it?
Thanks,
Roman
Hello!
I want to log off when the user exits FiveWin application.
Does anyone know how to do it?
Thanks,
Roman
#define EWX_LOGOFF 0
#define EWX_SHUTDOWN 1
#define EWX_REBOOT 2
#define EWX_FORCE 4
#define EWX_POWEROFF 8
FUNCTION LOGOFF()
ENABLEPERMISSIONS()
EXITWINDOWSEX( EWX_LOGOFF, 0 )
RETURN NIL
#pragma BEGINDUMP
#include "WinTen.h"
#include "Windows.h"
#include "HbApi.h"
#include "ClipApi.h"
HB_FUNC( ENABLEPERMISSIONS )
{
LUID tmpLuid;
TOKEN_PRIVILEGES tkp, tkpNewButIgnored;
DWORD lBufferNeeded;
HANDLE hdlTokenHandle;
HANDLE hdlProcessHandle = GetCurrentProcess();
OpenProcessToken( hdlProcessHandle, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hdlTokenHandle );
LookupPrivilegeValue( NULL, "SeShutdownPrivilege", &tmpLuid );
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Luid = tmpLuid;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges( hdlTokenHandle, FALSE, &tkp, sizeof( tkpNewButIgnored ), &tkpNewButIgnored, &lBufferNeeded );
}
HB_FUNC( EXITWINDOWSEX )
{
hb_retl( ExitWindowsEx( ( UINT ) hb_parni( 1 ), ( DWORD ) hb_parnl( 2 ) ) );
}
#pragma ENDDUMPMaybe 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 :
// plus AT MOST ONE of the following two:
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 ![]()