Following the advice of several members, especially Dragon, I have gotten
this routine to work. If you double click on your program's icon to load
it, and it is already running minimized into the sysem tray, it will just
reopen the running instance, not create another instance. Put this Function
into a Module in a DLL and call it like
If NoLoad(Me) then END
in your Form1.Load routine. This function returns TRUE if an instance is
already running, and False if this is the first instance to be loaded.
Bobbo
_______________________________________
Declare Auto Function FindWindow Lib "user32.dll" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Declare Auto Function ShowWindow Lib "user32.dll" _
(ByVal hWnd As IntPtr, ByVal nCmdShow As Integer) As Boolean
Public Function NoLoad(ByRef sender As System.Object) As Boolean
If UBound(System.Diagnostics.Process.GetProcessesByNa me( _
System.Diagnostics.Process.GetCurrentProcess.Proce ssName)) > 0 Then
Const SW_RESTORE As Integer = 9
Dim SearchText As String = sender.Text
sender.Text = sender.Text & "X"
Dim Handle As IntPtr = FindWindow(Nothing, SearchText)
ShowWindow(Handle, SW_RESTORE)
sender.Text = SearchText
Return True
Else
Return False
End If
End Function