DC_IsAppRunning() and CRT window

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
slobodan1949
Posts: 99
Joined: Mon Apr 25, 2011 8:57 am
Location: SERBIA
Contact:

DC_IsAppRunning() and CRT window

#1 Post by slobodan1949 »

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.
Attachments
RUNAPP.zip
(15.14 KiB) Downloaded 66 times

User avatar
rdonnay
Site Admin
Posts: 4868
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: DC_IsAppRunning() and CRT window

#2 Post by rdonnay »

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.

User avatar
slobodan1949
Posts: 99
Joined: Mon Apr 25, 2011 8:57 am
Location: SERBIA
Contact:

Re: DC_IsAppRunning() and CRT window

#3 Post by slobodan1949 »

Thanks for the new technique.

User avatar
Tom
Posts: 1299
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: DC_IsAppRunning() and CRT window

#4 Post by Tom »

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."

User avatar
slobodan1949
Posts: 99
Joined: Mon Apr 25, 2011 8:57 am
Location: SERBIA
Contact:

Re: DC_IsAppRunning() and CRT window

#5 Post by slobodan1949 »

This proved to be effective and simple. Thanks Tom.

User avatar
Tom
Posts: 1299
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: DC_IsAppRunning() and CRT window

#6 Post by Tom »

:)
Best regards,
Tom

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

Post Reply