Luca Olivetti wrote:
En/na Mattias Gärtner ha escrit:
Is there already a cross platform component for applications to check
if it is
already running and if yes then pass some commands to the already
application?
For example clicking on files in the file browser should not open a
second
instance, but tell the already running instance to open the files.
There's uniqueinstance
http://sourceforge.net/project/shownotes.php?group_id=92177&release_id=471823
(The wiki is down, so I cannot give you the wiki link) *but* it
doesn't work here under Linux (I could launch more that one instance
of my program).
Since I hadn't too much time to debug it, I slightly modified it to
open and lock a file instead of using TSimpleIpc, but that makes it
non-crossplatform.
Since it's short I'm including it here, it could be extended to write
the pid in the file, so another instance can somewhat contact the
first one.
It's working here both under win32 and linux (testraw and testcomponent
programs). Using fpc 220, Ubuntu Feisty Faw, recent lazarus svn.
The only missing feature under linux is the parameter list passing:
Under windows the SimpleIpc mechanism is integrated with the win32
message loop so the IPCServer.OnMessage is called without any further
intervention.
Under unix, SimpleIpc is not integrated with any message loop so
IPCServer.OnMessage is not called.
There are to ways of doing under unix:
- Hook in the LCL message loop to call PeakMessage
- Create a thread that will call PeakMessage at a time interval
In the below address you will find an updated component that hooks in
Application.OnIdle to call PeakMessage. Its far from optimal because
will prevent the use of OnIdle by the programmer and the parameter list
will be peaked only when the app is idle/has focus.
https://svn.bountysource.com/luipack/trunk/uniqueinstance
If someone knows a way to hook in LCL message loop to be called more
frequently than OnIdle or wants to implement a separeted thread i'm
accepting patches.
Luiz
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives