You want CreateMutex from Kernel32. Lots of documentation about it on the MSDN, of course, but something like this :
That's off the top of my head, so it might not be 100 percent.
EDIT: You may have to make some minor modifications to get the CreateMutex function to link properly, but the site won't let me post them. Sorry about that.
Extern "Win32" Function GetLastError:Int() = "GetLastError" Function CreateMutex:Int(lpMutexAttributes:Int,bInitialOwner:Int,lpName$z) End Extern Const ERROR_ALREADY_EXISTS:Int=183 CreateMutex(0,1,"My Program Instance") If GetLastError() = ERROR_ALREADY_EXISTS Then ' PROGRAM IS ALREADY RUNNING - SHUTDOWN Else ' PROGRAM IS NOT RUNNING, GO AHEAD EndIf
That's off the top of my head, so it might not be 100 percent.
EDIT: You may have to make some minor modifications to get the CreateMutex function to link properly, but the site won't let me post them. Sorry about that.