Run only one instance of your application: Difference between revisions

From DataFlex Wiki
Jump to navigationJump to search
m
No edit summary
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 Object put this piece of code:
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 iVoid
     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 ===


3

edits

Navigation menu