Hi
Need some help here....
I am running a application (PB 7.0.3) on a Windows 2003 server. This application is starting automatical when the server reboot, and is starting on the Consol session with user "X". Then if I or some other log on to this server with user "X" again, but not to the Console session, then this application starts up for the second time, and this MUST NOT HAPPEND.
I have coded so in the same session you cannot start the program twice, but it dont work over different sessions.
I use this code:
[External functions]
FUNCTION ulong CreateMutexA (ulong lpMutexAttributes, boolean bInitialOwner, REF string lpszName) LIBRARY "kernel32.dll"
FUNCTION long GetLastError() LIBRARY "kernel32.dll"
////////////////////////////////////////////////////
FUNCTION boolean of_IsRunning()
////////////////////////////////////////////////////
constant ulong ERROR_ALREADY_EXISTS = 183
constant ulong SUCCESSFUL_EXECUTION = 0
//
ulong lul_mutex
ulong lpsa
ulong lul_last_error
boolean lb_ret = FALSE
//
IF NOT (Handle(GetApplication()) = 0) THEN
lul_mutex = CreateMutexA(lpsa, FALSE, as_appname)
lul_last_error = GetLastError()
lb_ret = NOT (lul_last_error = SUCCESSFUL_EXECUTION)
END IF
//
RETURN lb_ret
Is there someone that know how to solve this ?
Regards
Kongsjs
Need some help here....
I am running a application (PB 7.0.3) on a Windows 2003 server. This application is starting automatical when the server reboot, and is starting on the Consol session with user "X". Then if I or some other log on to this server with user "X" again, but not to the Console session, then this application starts up for the second time, and this MUST NOT HAPPEND.
I have coded so in the same session you cannot start the program twice, but it dont work over different sessions.
I use this code:
[External functions]
FUNCTION ulong CreateMutexA (ulong lpMutexAttributes, boolean bInitialOwner, REF string lpszName) LIBRARY "kernel32.dll"
FUNCTION long GetLastError() LIBRARY "kernel32.dll"
////////////////////////////////////////////////////
FUNCTION boolean of_IsRunning()
////////////////////////////////////////////////////
constant ulong ERROR_ALREADY_EXISTS = 183
constant ulong SUCCESSFUL_EXECUTION = 0
//
ulong lul_mutex
ulong lpsa
ulong lul_last_error
boolean lb_ret = FALSE
//
IF NOT (Handle(GetApplication()) = 0) THEN
lul_mutex = CreateMutexA(lpsa, FALSE, as_appname)
lul_last_error = GetLastError()
lb_ret = NOT (lul_last_error = SUCCESSFUL_EXECUTION)
END IF
//
RETURN lb_ret
Is there someone that know how to solve this ?
Regards
Kongsjs