#Define AtomStrLength 512
Local lcAtomName
lcAtomName = "mon application"
Declare Integer GlobalAddAtom In win32api String
Declare Integer GlobalDeleteAtom In win32api Integer
Declare Integer GlobalGetAtomName In kernel32;
INTEGER nAtom,;
STRING @ lpBuffer,;
INTEGER nSize
findAtom(lcAtomName)
Function findAtom(tcAtom)
Create Cursor cs (atom N(12), strlen N(5), Name C(100))
Index On Allt(Name) Tag Name
For nAtom = 49152 To 65535
lpBuffer = Repli(Chr(0), AtomStrLength)
lnResult = GlobalGetAtomName (nAtom, @lpBuffer, AtomStrLength)
If lnResult > 0
Insert Into cs Values (nAtom, lnResult, Left(lpBuffer, lnResult))
Endif
Endfor
Select cs
If Seek(tcAtom)
Messagebox("Application is already running")
Quit
Else
= GlobalAddAtom(tcAtom)
Endif