>
> SUMMARY: On Windows, each time the user double clicks a data file, a
> separate copy of my app is opened. It should open the original
> instance. Can this be done?
It can be done, yes. Outlook does this, f.ex.
The norm on Windows IS to open multiple applications. You as the developer
can
however force a single instance as a part of your code.
The trick is: check if another instance of the application is running in the
current users context.
That is, if the user who started the application has another instance
running,
send a message to that instance to handle the file request, and then shut
down the duplicate.
Beware tho that other users MAY be running the application as well. You
wouldn't want
to send a message to those applications ( you really shouldn't be able to,
but hey... accidents may happen )
>
>
> DETAIL:
> I've modified the registry (thanks to the MBS plugin) to make my app
> open when a .OTD file is double clicked.
That modification should only need to be done once. Calling it every time
you start the
application is unneccessary overhead.
>
> I accept that on Windows double clicking the app icon again itself
> will open a second copy of your app and there are ways to handle this
> as previously posted to the list.
>
> Double clicking a document icon again and having the same document
> open in 2 separate copies of an app seems like undesirable behaviour
> for any app.
No, it's actually very desireable for many applications. My IDE opens up a
new
instance of itself whenever I doubleclick a project file. It however does
check if another instance is open, and asks me if I want to use the same
instance
or a new one.
Same goes for WordPad, Notepad and Calculator - I can start as many as I
want to.
It is actually very undesireable to do it as Apple does - one instance only,
and never
more than one. ( I regualrily use several instances of Calculator f.ex. - on
my Mac, I have
to have many installed calculators with different names to accomplish that )
>
> The only solution I can see is to use Mutex to detect if your app is
> already running and then use local network communication to talk to
> the other instance of your app and tell it to load this document if
> needed. Is there a more elegant solution? Is there a way to stop a
> separate instance from opening at the source?
A mutex may solve it, if the mutex is visible across processes. ( I think
its only visible across threads
within the same process ).
You may use shared memory, RPC, RMI ( a bit more complicated than RPC, but
quite a lot more powerful )
/Þór
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>