Detect if application is already open

Hi John,

  1. In the App add the property
    mMutex As Mutex

  2. in the event handler App.Open add the following code:
    mMutex = New Mutex(App.ExecutableFile.Name)
    If Not mMutex.TryEnter Then
    MessageBox(“Application already running”)
    Quit
    End If

  3. in the event handler App.Close add the following code to release the mutex
    If mMutex <> Nil Then
    mMutex.Leave
    End If

// ------------------

Best regards

4 Likes