Dear Roger,
is it possible to correct the function DC_IsAppRunning("XbpPmtClass","",appname(),.T.)
which will work correctly with Xbase++ CRT APP Window - SetAppWindow() when the
application does not use APPSYS.PRG. If possible, I would like to ask for it.
In my example, which I am attaching, the function DC_IsAppRunning does not work correctly,
while the function IntCnt(.T.) written in 2008 by Michael McVicker works correctly.
Also, the function IntCnt(.T.) works in the control: MsgBox(), ConfirmBox(), AlertBox()...
I am attaching the source code of the test program for both functions and the code
for the function IntCnt() in the RUNAPP.ZIP.
Note:
Until recently I thought that this with CRT windows was no longer needed by anyone.
But the need for this technique arose when training new users of
Alaska Xbase++ and eXpress++ who finally want to transfer their existing Clipper
applications to Xbase++ and eXpress++, because 64-bit Windows 11
no longer allows further play with Clipper.
DC_IsAppRunning() and CRT window
- slobodan1949
- Posts: 99
- Joined: Mon Apr 25, 2011 8:57 am
- Location: SERBIA
- Contact:
DC_IsAppRunning() and CRT window
- Attachments
-
- RUNAPP.zip
- (15.14 KiB) Downloaded 66 times
Re: DC_IsAppRunning() and CRT window
Here is another way to do this:
Code: Select all
RunShell('/C TaskList.Exe /V /FO CSV > tasklist.csv' )
aTasks := DC_Csv2Array('tasklist.csv')
nFound := AScan(aTasks,{|a|a[1]=='RUNAPP.EXE'})
nFound := AScan(aTasks,{|a|a[1]=='RUNAPP.EXE'},nFound+1)
IF nFound > 0
Confirmbox(,"PROGRAM HAS ALREADY STARTED" + chr(13)+;
"RESTART IS NOT POSSIBLE" + chr(13)+;
appname(.t.),;
"1 STOP PROGRAM START",;
XBPMB_OK,XBPMB_CRITICAL,XBPMB_SYSMODAL)
QUIT
Else
Confirmbox(,"Instance: "+ Str(nFound) + chr(13)+;
appname(.t.),;
"1 PROGRAM IS STARTED",;
XBPMB_OK,XBPMB_INFORMATION,XBPMB_SYSMODAL)
EndIF
The eXpress train is coming - and it has more cars.
- slobodan1949
- Posts: 99
- Joined: Mon Apr 25, 2011 8:57 am
- Location: SERBIA
- Contact:
Re: DC_IsAppRunning() and CRT window
Thanks for the new technique.
Re: DC_IsAppRunning() and CRT window
We are using the API-function "CreateMutexA" (KERNEL32.DLL, together with "OpenMutexA") to create a "Mutex" within our application. A Mutex can only created once in a session (so this also works on a Terminal Server) by an application, and if another instance of the same application tries to do so, it fails, so an instance must already be running (we look for the ProcId then). Mutexes can be released at the end (ReleaseMutex), but this is not really needed, since they "die" then. Works great, only few lines of code.
Best regards,
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
- slobodan1949
- Posts: 99
- Joined: Mon Apr 25, 2011 8:57 am
- Location: SERBIA
- Contact:
Re: DC_IsAppRunning() and CRT window
This proved to be effective and simple. Thanks Tom.
Re: DC_IsAppRunning() and CRT window

Best regards,
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."