George Birbilis wrote:
I created a component to force one instance per application.
More info here: http://wiki.lazarus.freepascal.org/UniqueInstance
Was wandering if lock files could be used instead as more cross-platform
way.
UniqueInstance is written using standard fpc/Lazarus functions and
classes. No platform dependant hacks. All platform dependant code is
hidden by the FCL and the LCL. The only issue regarding diferent
platforms is that a feature of simpleipc is missing in unix (which only
affects the callback mechanic). Is just a question of implementing the
missing part.
First instance could make the lock file, the other instances could find
the lock file and just return. User could delete the lock file manually if
app fails to delete it. Problem is though:
1) need to notify running app somehow to come to front (maybe if it polls
the lock file for something being written into it or if there's some
notification for such action [I don't think there is])
My implementation already has such mechanism. See included examples.
2) the possibility of app remaining locked after a crash and user having to
delete a lock file manually is bad in usability terms (although I remember
[years ago] various Unix apps used to do that thing).
No such problems with UniqueInstance. If a app crashes other instances
can be initiated without problem.
On Windows btw, there are better ways than TCP/IP to do this stuff, for
example custom window messages or unique window names (using a GUID/UUID
maybe to guarantee uniqueness)
It's not using TCP/IP. See the implementation of simpleipc.
Anyway, anyone is free to do its own implementation or even modify it:
it's Open Source.
Luiz
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives