Have you considered using a command line parameter ?
Originally Posted by Bezzie
When restarting yourself use ShellExecute instead of Shell.
ShellExecute will let you pass a command parameter to the application your are starting, something like this:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Sub Command1_Click()
Call ShellExecute(Me.hwnd, "Open", App.Path & "\" & App.EXEName & ".exe", "Restart", "", 1)
Set Form1 = Nothing
'Call Shell(App.Path & "\" & App.EXEName & ".exe", 1)
You could then write code in your application checking the command line like this:
If (Command = "Restart") Then
'-- Do not check for previous instance.
'-- check for previous instance.
I'm just throwing out ideas.