RE: Single Application Instance Example



[DeRRudi]
|
| Whit this mutex is it possible when an instance is running in
| background and you try to open a new instance. you cancel it and show
| the first?
|
| Greetz

All the Mutex is doing is providing a single token
which only one instance of the app can hold at a
time. Of itself, it doesn't provide any facility to
awake background applications or do anything at all
except exclude other apps from holding the same
token.

What you describe could be achieved a number of ways.
(He says, sounding knowledegeable, but having little
real experience to back himself up). Once the Mutex
check proves that you're not the only instance running,
you could, for example, find the top-level window of your
app and activate it (assuming it has a window). You could
embed some sort of mini-messaging within the application,
say a small Pyro class, or a socket server, or a Windows
pipe, or whatever, which will let your second instance
send a message to the first which will then activate
(whatever that means).

In fact, you could probably combine the two by using a
private Windows pipe which would both serve as a "anyone
else here?" check and as a signal to an existing instance
to wake up and dance.

It all depends on what the app is doing, and how
hard you want to try.

TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
.



Relevant Pages

  • Re: Only One Instance.
    ... the secondary app the handle info of the original app along with what ... use the FINDWIndow in the Main Source before The ... The name of the mutex has no effect on anything else in your program, ... Creating a window, on the ...
    (comp.lang.pascal.delphi.misc)
  • Re: Pass in additional command line arguments to a single instance app
    ... Explorer to send the filename to my app. ... I use the existence of a window with a particular class name as the indicator that a "first instance" is running. ... An instance can not start (create the window), exit, or check for existence of the window unless it can acquire the mutex. ...
    (microsoft.public.vc.language)
  • Re: Only One Instance.
    ... use the FINDWIndow in the Main Source before The ... you could simply create a mutex. ... created the window that the other process is looking for. ... > your app responed to .. ...
    (comp.lang.pascal.delphi.misc)
  • Re: Steve Carroll does not know the difference between saving and quitting.
    ... or in an app where it can be used for additional work it ... Most apps cannot be used with no window open... ... yet it does not quit. ... And nor should it Snit! ...
    (comp.sys.mac.advocacy)
  • Re: Steve Carroll does not know the difference between saving and quitting.
    ... or in an app where it can be used for additional work it ... Most apps cannot be used with no window open... ... yet it does not quit. ... And nor should it Snit! ...
    (comp.sys.mac.advocacy)