Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #7880 > unrolled thread

Prevent Multiple Instances

Started byJames Martin <james@northwoodlumber.com>
First post2015-03-17 13:44 -0400
Last post2015-03-19 08:33 -0400
Articles 4 — 3 participants

Back to article view | Back to comp.lang.clipper.visual-objects


Contents

  Prevent Multiple Instances James Martin <james@northwoodlumber.com> - 2015-03-17 13:44 -0400
    Re: Prevent Multiple Instances JohnMartens <martens@tennishulp.info> - 2015-03-17 18:55 +0100
    Re: Prevent Multiple Instances "Craig Dawson" <craig_dawson@hotmail.com> - 2015-03-19 22:45 +1100
      Re: Prevent Multiple Instances James Martin <james@northwoodlumber.com> - 2015-03-19 08:33 -0400

#7880 — Prevent Multiple Instances

FromJames Martin <james@northwoodlumber.com>
Date2015-03-17 13:44 -0400
SubjectPrevent Multiple Instances
Message-ID<me9osc$d2h$1@dont-email.me>
I would like to know a simple way to prevent an app from running twice 
that avoids the problem of leaving a flag that prevents any further 
execution when the program terminates with an error.

James

[toc] | [next] | [standalone]


#7881

FromJohnMartens <martens@tennishulp.info>
Date2015-03-17 18:55 +0100
Message-ID<me9ppm$h3r$1@dont-email.me>
In reply to#7880
Long time ago I used this:

cMutex := 'APP_RUNS_IN_'+GetMyCurDir()
CreateMutex(NULL,TRUE,String2Psz(cMutex))
IF GetLastError() > 0
	** second run

Do not know if this still works. My help file referss tot Win95 ??!!

John


James Martin schreef op 17-3-2015 om 18:44:
> I would like to know a simple way to prevent an app from running twice
> that avoids the problem of leaving a flag that prevents any further
> execution when the program terminates with an error.
>
> James

[toc] | [prev] | [next] | [standalone]


#7886

From"Craig Dawson" <craig_dawson@hotmail.com>
Date2015-03-19 22:45 +1100
Message-ID<meecrr$3pc$1@dont-email.me>
In reply to#7880
Hi James,
I put the following at the start() of my app...
Works great!
Regards, Craig.

IF AlreadyRunning( "PNS.EXE" ) // Nice!
    oAppWin := AppWindow{}
    ErrorBox{oAppWin, "You can't launch this program twice at the same 
time!"}:Show()
    BREAK // STOP
ENDIF

FUNCTION AlreadyRunning( cID_APP AS STRING ) AS LOGIC
// Author : Richard Press (with lots of help)
CreateMutex(NULL,TRUE,String2Psz(cID_APP))
RETURN (GetLastError()==ERROR_ALREADY_EXISTS)



"James Martin" <james@northwoodlumber.com> wrote in message 
news:me9osc$d2h$1@dont-email.me...
>I would like to know a simple way to prevent an app from running twice that 
>avoids the problem of leaving a flag that prevents any further execution 
>when the program terminates with an error.
>
> James 

[toc] | [prev] | [next] | [standalone]


#7887

FromJames Martin <james@northwoodlumber.com>
Date2015-03-19 08:33 -0400
Message-ID<meefch$d1f$1@dont-email.me>
In reply to#7886
Looks good! John Martin's solution worked the same way, and it works. 
I'll use your code on another program.

James

On 15-03-19 07:45 AM, Craig Dawson wrote:
> Hi James,
> I put the following at the start() of my app...
> Works great!
> Regards, Craig.
>
> IF AlreadyRunning( "PNS.EXE" ) // Nice!
>      oAppWin := AppWindow{}
>      ErrorBox{oAppWin, "You can't launch this program twice at the same
> time!"}:Show()
>      BREAK // STOP
> ENDIF
>
> FUNCTION AlreadyRunning( cID_APP AS STRING ) AS LOGIC
> // Author : Richard Press (with lots of help)
> CreateMutex(NULL,TRUE,String2Psz(cID_APP))
> RETURN (GetLastError()==ERROR_ALREADY_EXISTS)
>
>
>
> "James Martin" <james@northwoodlumber.com> wrote in message
> news:me9osc$d2h$1@dont-email.me...
>> I would like to know a simple way to prevent an app from running twice that
>> avoids the problem of leaving a flag that prevents any further execution
>> when the program terminates with an error.
>>
>> James
>
>

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.clipper.visual-objects


csiph-web