Parse Command Line Parameters

S

slonocode

I have created a filter in Eudora email program that will notify a
program when the criteria is met. For instance if the filter criteria
is met it will send the following command:

C:\MyProgam.exe "C:\MyFile.txt"

I have been able to process the command line by writing a small sub main
in a module and that works fine. But I need for their to be only 1
instance of the program. As it is now it opens a new instance of
MyProgram.exe every time the command line is called. So I need the
program to execute the first time the command line is called and then
just process any new command line calls and not open a new instance.

My module looks as follows:

Dim _filename As String

Public Sub Main(ByVal args() As String)
Dim s As String
For Each s In args
ParseArgs(s)
Next
Application.Run(New Form1)
End Sub

Public Sub ParseArgs(ByVal s As String)
MessageBox.Show(s)
_filename = s
End Sub

Public ReadOnly Property Filename() As String
Get
Return _filename
End Get
End Property

How can I do that?
 
B

Bob Powell [MVP]

Windows Forms Tips and Tricks will show you how to activate the running
instance of the program. I'll think about how to pass the parameters
tomorrow ;-)

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 

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