I'll have several computers (not always connected to the network, not always the same IP...) that will do some work on the same network resource. They must not do it at the same time. I'm wondering if there's a simple way to know whether a process is already doing its work.
I tried to make a lock file with this draft:
Code: Select all
on mouseUp
put specialFolderPath("desktop")&"/myLock.txt" into lockName
if the short name of the target is "btnLck" then
if fld "fldRes" is "locked by me" then exit mouseUp
if there is a file lockName then
put "locked by another process" into fld "fldRes"
else
open file lockName for write
put "locked by me" into fld "fldRes"
end if
else if the short name of the target is "btnRel" and fld "fldRes" is "locked by me" then
close file lockName
delete file lockName
put "released" into fld "fldRes"
end if
end mouseUp
on preOpenStack
put empty into fld "fldRes"
end preOpenStack
I also tried to see if the result of open file told us "file locked" (as MS Word does) but it doesn't
Am I forced to make a DLL and use Windows API?