Goodmorning
I have built a program of which I wish only one instance opened at time. To do this, I used Mutex and related API calls:
Now there's my problem...Code:Function Is2ndInstance() As Boolean Dim hMutex As Long hMutex = CreateMutex(ByVal 0&, 1, App.Title) If (Err.LastDllError = ERROR_ALREADY_EXISTS) Then Is2ndInstance = True ReleaseMutex hMutex CloseHandle hMutex End If End Function Private Sub Form_Load() If Is2ndInstance Then End If Command <> "" Then 'Code to open file End If End Sub
I'm trying to give user the possibility to open files simply clicking on them and use the path stored into Command function to load them into my application. The first time user tries to open a file, it is successfully opened. But if he tries again, the Mutex doesn't allow and closes the second instance of the program without opening the file chosen.
What can I do to open all files into the same instance of my application (avoiding my program is opened twice or more) ? Moreover I succeeded to use Command only if I select what program I want to open the file with (using the Open As... option in the contex Menu). In fact, the double click on the file didn't make anything useful. Why?
Thank you all.
![]()





Reply With Quote