How do I pass a command line to another instance of my application which is already running

P

pamela fluente

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.StartupEventArgs)
Handles Me.Startup

G_CommandLine = e.CommandLine

Dim intAppInstances As Integer =
UBound(Diagnostics.Process.GetProcessesByName(Diagnostics.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
 
G

Guest

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
 
P

pamela fluente

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















- Mostra testo tra virgolette -

good idea: I will try that out. Thank you Kerry .

-P
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top