Board index » delphi » One App Instance--pass the ParamStr to the open app

One App Instance--pass the ParamStr to the open app

Hi all--

   I've seen a number of different ways of preventing multiple instances of
an application.  I'd like to do what Word 97 does--if you were to click on a
Word document in Explorer while Word was already running, the current
version of Word will open the file.  How can I pass the new ParamStr to the
previous instance?

Thanks as always,

Christopher Sansone

 

Re:One App Instance--pass the ParamStr to the open app


Our TApplicata does both instance counting/limit and parametter
passing. All in one :)
_____________________________________________
Gintaras Pikelis
Baltic Solutions
http://www.balticsolutions.com

Re:One App Instance--pass the ParamStr to the open app


Quote
>    I've seen a number of different ways of preventing multiple instances of
> an application.  I'd like to do what Word 97 does--if you were to click on a
> Word document in Explorer while Word was already running, the current
> version of Word will open the file.  How can I pass the new ParamStr to the
> previous instance?

Christopher,

one of the methods you mentioned is to use FindWindow in your DPR file, before
the seconds instance has created its main form, to find the first instances
main form. Once you have that you can send messages to the form via
SendMessage. So pack up the parameter list into a buffer, e.g. a string with
some separator character between parameters (#13#10 is ideal since you can
assign the string to a stringlist.text property to take it apart), then send
the buffer with a WM_COPYDATA message to the first instance main form. The
forms needs a handler for that message, of course.

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitely requested!

Other Threads