Hi, José, I am experiencing one of my hair pulling out periods again and hoping you can help me out.
I am using this Function
Code: Select all
Function InstanceTest() As Long
Dim hMutex As Handle
Dim ThisApp As Wstring * Max_Path
Dim LastError As Long
ThisApp = "WinFBE64-2.1.3" ' tried "WinFBE64-2.1.3.exe" to no avail
hMutex = CreateMutexW( ByVal Null, ByVal Null, VarPtr(ThisApp) )
LastError = GetLastError
If hMutex <> 0 Then
If LastError = Error_Already_Exists Then
Function = FALSE
Else
Function = TRUE
End If
Else
ThisApp = "Mutex Create failed with error code" + Str(LastError)
Messagebox( Byval NULL, ThisApp, "Cswitches2", MB_OK )
Function = FALSE
End If
End Function
In WndProc I have
Code: Select all
Select Case uMsg
Case WM_CREATE
SetTimer( hDlg, IDC_Timer, 5000, null ) ' 5000 to allow me to watch
Case WM_TIMER
If InstanceTest = 0 Then
Print "Here"
Sleep 1000 ' 1000 to allow me to watch
KillTimer hDlg, IDC_Timer
PostQuitMessage(0)
Exit Function
End If
What I want is for my application to close when "WinFBE64-2.1.3" closes and not before.
When running "WinFBE64-2.1.3.exe" shows in "Process Explorer"
On the face of it, it would seem that there is something wrong with InstanceTest() but I cannot see it.