Run only one instance of your application: Difference between revisions
From DataFlex Wiki
Jump to navigationJump to search
Run only one instance of your application (view source)
Revision as of 09:01, 24 October 2007
, 24 October 2007→Using mutexes
Paolo.bruno (talk | contribs) No edit summary |
Paolo.bruno (talk | contribs) m (→Using mutexes) |
||
Line 10: | Line 10: | ||
Here is the code if you want to go that route." | Here is the code if you want to go that route." | ||
In the SRC file within the panel | In the SRC file within the panel object put this piece of code: | ||
Procedure Exit_Application | Procedure Exit_Application | ||
integer iVoid | integer iVoid | ||
If (ghMuteX) Move (CloseHandle(ghMutex)) to iVoid | If (ghMuteX) Move (CloseHandle(ghMutex)) to iVoid | ||
move 0 to | move 0 to ghMuteX | ||
Forward Send Exit_Application | Forward Send Exit_Application | ||
End_Procedure | End_Procedure | ||
Line 20: | Line 20: | ||
// Constants | // Constants | ||
Define ERROR_INVALID_HANDLE for 6 // taken from error.h of VS7 | Define ERROR_INVALID_HANDLE for 6 // taken from error.h of VS7 | ||
Define ERROR_ALREADY_EXISTS for 183 | Define ERROR_ALREADY_EXISTS for 183<br/> | ||
Handle ghMuteX<br/> | |||
Handle ghMuteX | |||
// external functions | // external functions | ||
#IFNDEF Get_CreateMuteX | #IFNDEF Get_CreateMuteX | ||
Line 29: | Line 28: | ||
#IFNDEF Get_CloseHandle | #IFNDEF Get_CloseHandle | ||
External_Function CloseHandle "CloseHandle" Kernel32.dll Integer i1 Returns Integer | External_Function CloseHandle "CloseHandle" Kernel32.dll Integer i1 Returns Integer | ||
#ENDIF | #ENDIF<br/> | ||
// function to create a mutex | // function to create a mutex | ||
Procedure Create_MuteX_Object | Procedure Create_MuteX_Object | ||
Line 49: | Line 48: | ||
End | End | ||
Else Send None // rare error; object could not be created | Else Send None // rare error; object could not be created | ||
End_Procedure // Create_MuteX_Object | End_Procedure // Create_MuteX_Object<br/> | ||
// create the mutex | // create the mutex | ||
Send Create_MuteX_Object | Send Create_MuteX_Object | ||
=== Using FindWindow WinAPI === | === Using FindWindow WinAPI === | ||