Pamela,
In VB 2005 you can select "Make single instance application" in the
application's Properties to create a single instance app.
When an attempt is made to start the app and it is already running, the
My.Application.StartupNextInstance event is raised. This event is provided a
StartupEventArgs object that contains the application's command-line
arguments.
Kerry Moorman
"pamela fluente" wrote:
>
I have an application running. A file type is registered with this
application. When the user click on a file of such type a new instance
of the application is loaded with command line (file name).
I want to shut done this new instance an to notify the instance which
is already running, by passing the command line to it (so that the
file can be open by the application already runnning).
Here is my code, how do I notify the running instance ?
Partial Friend Class MyApplication
Private Sub MyApplication_Startup(ByVal sender As Object,
ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupE ventArgs)
Handles Me.Startup
G_CommandLine = e.CommandLine
Dim intAppInstances As Integer =
UBound(Diagnostics.Process.GetProcessesByName(Diag nostics.Process.GetCurrentProcess.ProcessName))
If intAppInstances 0 Then
MsgBox("Application already running")
' Here I want to notify the instance of the
application
'which is already running and pass to it the
CommandLine
' == how? ==
e.Cancel = True
End If
End Sub
End Class