Thank you again for getting back to me (and for your
patience

. Unfortunately for me, my background with
processes ranges anywhere from weak to non-existent. My
problem is in getting the hwnd value required by
ShowWindow(ExecutingProcesses
(0).MainWindowHandle.ToInt32,SW_SHOWNORMAL)
and also same problem with SetForegroundWindow....
VB.net is complaining that 'ExecutingProcesses' isn't
declared. I placed the Dim and If Then statements in the
Form's Load Event. It works if I comment out
ShowWindow... and SetForegroundWindow... lines.
If I may bother you one more time (if not, don't worry -
I'll read up on thess APIs), but is there another way to
obtain the hwnd value than ExecutingProcesses? Can I get
it from the RunningProcesses var?
Thanks for your help,
Rich
-----Original Message-----
It's basically an array of all the processes with the
name of the current application. In the code I sent
previously, RunningProcesses was declared just before
the "If" statement as shown below.
Dim RunningProcesses as Process() = Process.GetProcessesByName(aProcName)
Here's the code for the main routine again...
Dim aModuleName As String =
Diagnostics.Process.GetCurrentProcess.MainModule.ModuleNam e
Dim aProcName As String =
System.IO.Path.GetFileNameWithoutExtension(aModuleName)
Dim RunningProcesses as Process() = Process.GetProcessesByName(aProcName)
If RunningProcesses.Length > 1 Then
' Show previous instance
ShowWindow(ExecutingProcesses (0).MainWindowHandle.ToInt32,
(0).MainWindowHandle.ToInt32)
' Exit application
Application.Exit()
End If
"Rich" <anonymous@discussions.microsoft.com> wrote in
message news:a89901c406f3$767f99b0$a501280a@phx.gbl...