I would like to prevent the user from launching a second copy of my Clarion app. So far the instruction “don’t click on the shortcut icon multiple times” hasn’t been particularly effective.
In VB.NET I can select “Make Single instance application” and there is an option to only load one instance of the Clarion IDE, but what about only one copy of the application?
In VB6 I have the following code to detect multiple instances of my Zippy.exe application:
Sub ActivatePrevInstance() '// Activate the previous instance of the application Dim OldTitle As String Dim PrevHndl As Long Dim result As Long 'Save the title of the application. OldTitle = App.Title 'Rename the title of this application so FindWindow 'will not find this application instance. App.Title = "Zippy!" 'Attempt to get window handle using VB class name. PrevHndl = FindWindow(vbNullString, OldTitle) 'Check if found If PrevHndl = 0 Then ' IF 1 'No previous instance found. App.Title = OldTitle Exit Sub End If ' IF 1 'Get handle to previous window. PrevHndl = GetWindow(PrevHndl, GW_HWNDPREV) 'Restore the program. result = OpenIcon(PrevHndl) 'Activate the application. result = SetForegroundWindow(PrevHndl) End End Sub 'ActivatePrevInstance
I’m sure someone has written something similar for Clarion. It may even be in one of the many examples, but I’m having difficulty finding it. Any suggestions?