sending new parameters to existing instance

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

sending new parameters to existing instance

Zaaphod
I have a windows console application I wrote with Freepascal.    I can send it a command line parameter for a file to use have it working so if I just double click on the file I wish to open with my program, it launches and opens it.   I am wondering how I can set it up so that double clicking a second file will just load the new file into the first instance instead of opening a second instance of the program.   I've been thinking up schemes for how this could be done, but I think there must be some system in place that does this already because a lot windows programs behave this way, just loading the new file into the existing instance, but I'm not familiar enough with how this is done.   Could someone please point me in the right direction on how this is typically done?

James


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: sending new parameters to existing instance

wkitty42
On 08/27/2017 12:18 PM, James Richters wrote:

> I have a windows console application I wrote with Freepascal.    I can send
> it a command line parameter for a file to use have it working so if I just
> double click on the file I wish to open with my program, it launches and
> opens it.   I am wondering how I can set it up so that double clicking a
> second file will just load the new file into the first instance instead of
> opening a second instance of the program.   I've been thinking up schemes for
> how this could be done, but I think there must be some system in place that
> does this already because a lot windows programs behave this way, just
> loading the new file into the existing instance, but I'm not familiar enough
> with how this is done.   Could someone please point me in the right direction
> on how this is typically done?

i think you're looking for IPC (InterProcess Communication)... with this, the
second instance would load up, find that there is one already running, tell the
already running one about the new file to load, and then exit...


--
  NOTE: No off-list assistance is given without prior approval.
        *Please keep mailing list traffic on the list unless*
        *a signed and pre-paid contract is in effect with us.*
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: sending new parameters to existing instance

Zaaphod
>i think you're looking for IPC (InterProcess Communication)... with this, the second instance would load up, find that there is one already running, tell the already running one about the new file to load, and then exit...

Thank you, that is exactly what I want but did not know what it was called.

James

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: sending new parameters to existing instance

noreply
On 2017-08-27 14:52, James Richters wrote:

>> i think you're looking for IPC (InterProcess Communication)... with
>> this, the second instance would load up, find that there is one
>> already running, tell the already running one about the new file to
>> load, and then exit...
>
> Thank you, that is exactly what I want but did not know what it was
> called.
>
> James
>

http://wiki.lazarus.freepascal.org/SimpleIPC

FPC has its own ipc unit that makes it pretty easy, and I ported it to a
DLL so that any program in any language can communicate with an fpc
program
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: sending new parameters to existing instance

Luca Olivetti-2
In reply to this post by Zaaphod
El 27/08/17 a les 21:52, James Richters ha escrit:
>> i think you're looking for IPC (InterProcess Communication)... with this, the second instance would load up, find that there is one already running, tell the already running one about the new file to load, and then exit...
>
> Thank you, that is exactly what I want but did not know what it was called.

And here's simple wrapper around ipc to do what you want to do:
http://wiki.freepascal.org/UniqueInstance

Bye
--
Luca
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal