On 2005-03-09, André <An**@discussions.microsoft.com> wrote:
Hi,
How do I create an win 32 app and pass parameters to have it respond to the
passed values?
Like winzip "winzip32 -a"
Kinda like Console args but I want to be able to call it via Start run
helloworld.exe ? something
Can someone post a simple example or a link?
vb.net or C#
Thank you
class MainForm : System.Windows.Forms
{
[STAThread ()]
public static void Main (string[] args)
{
foreach (string arg in args) {
ParseArg (arg);
}
Application.Run (new MainForm ());
}
private static void ParseArg (string arg)
{
MessageBox.Show (arg);
}
}
Obviously, you'll want to do something to the arguments. In VB.NET you
can do the exact same thing - you just declare Main like this:
<STAThread ()> _
Public Shared Sub Main (ByVal args() As String)
End Sub
or
<STAThread ()> _
Public Shared Function Main (ByVal args() As String) As Integer
End Sub
The VB.NET designer creates a hidden main method if you don't supply it.
So, all you have to do is type in the method signature and you are good
to go.
--
Tom Shelton [MVP]