Board index » delphi » How can I stop a program from running more than once.

How can I stop a program from running more than once.

    I guess the Subject says it all. How can i detect if the program is
already running in memory? Thanks,

Fred
NDS

 

Re:How can I stop a program from running more than once.


Quote
Frederick A. Lajoie wrote in message <36FAA707.986EB...@istar.ca>...

>    I guess the Subject says it all. How can i detect if the program
is
>already running in memory? Thanks,

Are you talking about DOS programming here? like trying to prevent
someone starting the BP IDE when the BP IDE has shelled to DOS?

You can walk the MCB chain to see if there is a program of the same
name already running. http://www.zekes.com/~blunt/index.htm may have
something on this, or I could email you some Pascal source. But the
problem with that is, there is no way to ensure your program name is
unique.

You could hook an unused interrupt vector, point it at a string in
your program, with an ExitProc to restore the vector; then, before
your program does anything, see if that vector is already pointing at
the string.

FP

Re:How can I stop a program from running more than once.


In article <7dg26t$4j...@ezekiel.eunet.ie>, Frank Peelo
<fpe...@indigo.ie> writes

Quote
>You could hook an unused interrupt vector, point it at a string in
>your program, with an ExitProc to restore the vector; then, before
>your program does anything, see if that vector is already pointing at
>the string.

And if the program terminates abnormally before restoring the vector? Or
if the string is still{*word*154} around in memory after a normal
termination? What then?

--
Marcus Morris - South Croydon, LONDON, UK (Mar...@ntos.demon.co.uk)

Re:How can I stop a program from running more than once.


Quote
Marcus Morris wrote:
> In article <7dg26t$4j...@ezekiel.eunet.ie>, Frank Peelo
> <fpe...@indigo.ie> writes

> >You could hook an unused interrupt vector, point it at a string in
> >your program, with an ExitProc to restore the vector; then, before
> >your program does anything, see if that vector is already pointing at
> >the string.

> And if the program terminates abnormally before restoring the vector? Or
> if the string is still{*word*154} around in memory after a normal
> termination? What then?

The string won't hang around because in termination of the first program, you
would restore the original interrupt vector.  The location of the string
becomes non-issue.  Look up help on ExitProc to see what you need to do.

Quote
> --
> Marcus Morris - South Croydon, LONDON, UK (Mar...@ntos.demon.co.uk)

--
Scott Earnest            | SPAM protection in effect. Remove  |
setech@_ix.netcom.com    | "_" as needed for true addresses.  |
earnests@_homenet.lm.com |    UIN:1136443  EFnet:pale_blue    |
sinykal@_{*word*104}space.org  | URL: http://www.netcom.com/~setech |

Re:How can I stop a program from running more than once.


In article <36FDE959.D6F83603@_ix.netcom.com>, Scott Earnest
<setech@_ix.netcom.com> writes

Quote
>The string won't hang around because in termination of the first program, you
>would restore the original interrupt vector.  The location of the string
>becomes non-issue.  Look up help on ExitProc to see what you need to do.

But if your program terminates abnormally, does the exit procedure get
called? "Help" doesn't seem to be clear on this.

In fact, "Help" on ExitProc in TP7 is downright misleading. It claims,
finally, to return you to "Windows" - which is simply not true. I get
returned to DOS (as I would both hope and expect).

--
Marcus Morris - South Croydon, LONDON, UK (Mar...@ntos.demon.co.uk)

Re:How can I stop a program from running more than once.


Quote
Marcus Morris wrote:
> In article <36FDE959.D6F83603@_ix.netcom.com>, Scott Earnest
> <setech@_ix.netcom.com> writes

> >The string won't hang around because in termination of the first program, you
> >would restore the original interrupt vector.  The location of the string
> >becomes non-issue.  Look up help on ExitProc to see what you need to do.

> But if your program terminates abnormally, does the exit procedure get
> called? "Help" doesn't seem to be clear on this.

So long as it quits by way of RTE, yes, it will be called.  I've used this
method a number of times in programs to unhook ISRs (Interrupt Service
Routines).

Quote
> In fact, "Help" on ExitProc in TP7 is downright misleading. It claims,
> finally, to return you to "Windows" - which is simply not true. I get
> returned to DOS (as I would both hope and expect).

Where did you see this?  I have BP7, which *does* support Windows, and I see
no such claim in my manuals.

Quote
> --
> Marcus Morris - South Croydon, LONDON, UK (Mar...@ntos.demon.co.uk)

--
Scott Earnest            | SPAM protection in effect. Remove  |
setech@_ix.netcom.com    | "_" as needed for true addresses.  |
earnests@_homenet.lm.com |    UIN:1136443  EFnet:pale_blue    |
sinykal@_{*word*104}space.org  | URL: http://www.netcom.com/~setech |

Other Threads