A while ago I grabbed this code from the PureBasic forums to avoid multiple startup of my written programs.
The question is if this code is still sufficient or maybe outdated.
It is doing its task but.. maybe there are better ways?
Example:
Code: Select all
;- Mutex Creation
MutexID=CreateMutex_(0,1,"My Program")
MutexError=GetLastError_()
If MutexID=0 Or MutexError<>0
ReleaseMutex_(MutexID)
CloseHandle_(MutexID)
End
EndIf
If OpenWindow(0,300,300,200,100,"My Program")
While WaitWindowEvent() <> #PB_Event_CloseWindow : Wend
EndIf
;- Mutex Close
CloseHandle_(MutexID)
End