Detect if an application is already runningTag(s): WinAPI/Registry
[external function declaration]
FUNCTION ulong CreateMutexA &
(ulong lpMutexAttributes, boolean bInitialOwner, REF string lpszName) &
LIBRARY "kernel32.dll"
FUNCTION long GetLastError() LIBRARY "kernel32.dll"
[powerscript]
// boolean of_IsRunning()
//
// IF of_isRunning THEN
// MessageBox("Oups", "already running!")
// END IF
//
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
mail_outline
Send comment, question or suggestion to howto@rgagnon.com
Send comment, question or suggestion to howto@rgagnon.com