-mhd
2012-10-14 01:30:34 UTC
Normally when I detect a running instance of my prog by using a mutex value, I
just kill the second instance but now I also want to bring the first instance up
to normal state if its minimized.
MutexValue = CreateMutex(ByVal 0&, 1, "MyProgMutex")
If (Err.LastDllError = ERROR_ALREADY_EXISTS) Then
CloseHandle MutexValue
'Search for Window / Get its Handle
lhwnd = FindWindow(vbNullString, "My Prog Caption")
'If Another Window Found
If lhwnd <> 0 Then
'Activate and Show Window
lRtrn = ShowWindow(lhwnd, SW_SHOWRESTORE)
End If
'this instance exits sub main and dies
Exit Sub
End If
Works just great in the IDE as the first instance pops up from minimized state
and the second one dies.
When compiled the second one dies immediately upon launching as intended but the
first one doesn't pop up.
Any ideas?
-mike
just kill the second instance but now I also want to bring the first instance up
to normal state if its minimized.
MutexValue = CreateMutex(ByVal 0&, 1, "MyProgMutex")
If (Err.LastDllError = ERROR_ALREADY_EXISTS) Then
CloseHandle MutexValue
'Search for Window / Get its Handle
lhwnd = FindWindow(vbNullString, "My Prog Caption")
'If Another Window Found
If lhwnd <> 0 Then
'Activate and Show Window
lRtrn = ShowWindow(lhwnd, SW_SHOWRESTORE)
End If
'this instance exits sub main and dies
Exit Sub
End If
Works just great in the IDE as the first instance pops up from minimized state
and the second one dies.
When compiled the second one dies immediately upon launching as intended but the
first one doesn't pop up.
Any ideas?
-mike