RunRev Application
FlexibleLearning
admin at FlexibleLearning.com
Sun Apr 24 13:13:57 EDT 2011
Hi Warren,
This is for Windows, but the same principle should work on a Mac also.
>From The Scripter's Scrapbook (www.ssbk.co.uk):
Detecting a second instance of an application under Windows.
You create a 'known' file on the system disk somewhere and open it with a
lock - if the file isn't there or isn't locked, it means the engine isn't
currently running.
"The lock is owned by the currently running instance of the engine and is
there just in case the running instance 'goes away' without deleting the
file. On Windows, locks are always cleaned up when an application quits - so
a second instance of an engine can always detect if there is already an
instance running by first checking for existence and then trying to delete
the file if present - if the delete succeeds it means the owning instance
has indeed 'gone away'.
"IIRC, at present the lock is just implemented via keeping an open file
handle with a given share-mode - although, just keeping the file open would
probably suffice now that I come to think of it (all files opened by an
application are also implicitly closed on exit).
"Anyway, the idea behind the 'lock' idea is that it ensures you can (without
fail) detect if there is a running instance - even if a previous instance
has left its identifying file behind by mistake."
------------------
Sample by FLCo for Revolution...
on startUp
local dummy
put specialFolderPath(35) &"/myAppDummy" into dummy
if there is a file dummy then
delete file dummy
if the result is not empty then
answer "2nd Instance" with "QUIT"
quit
end if
end if
open file dummy
end startUp
on closeStack
local dummy
put specialFolderPath(35) &"/myAppDummy" into dummy
delete file dummy
end closeStack
------------------------------
On Sun, 24 Apr 2011 11:55:46 Warren Kuhl wrote:
Is there a way to prevent multiple occurrences of a RunRev application to
open?
Thanks,
Warren
More information about the use-livecode
mailing list