473,378 Members | 1,236 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

win32 app pass Parameters

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

Nov 22 '05 #1
9 1636
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]
Nov 22 '05 #2
Andre,

You can pass the information using an array of strings

I hope this helps?

Cor
Nov 22 '05 #3
That's the strangest .vb code I have ever seen! :)

Nov 22 '05 #4
Wow, That was easy.

Thanks all for the help.
"Tom Shelton" wrote:
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]

Nov 22 '05 #5
Tom,

"Tom Shelton" <ts******@YOUKNOWTHEDRILLcomcast.net> schrieb:
<STAThread ()> _
Public Shared Function Main (ByVal args() As String) As Integer
End Sub


'STAThread' is IMO added implicitly, no need to specify it in VB.NET.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 22 '05 #6
Herfried,
'STAThread' is IMO added implicitly, no need to specify it in VB.NET.


It is not even needed to create a Shared Function Main, that is build in in
VB.Net.

Although I find it foolish to use it in VB.Net is everybody in my opinion
free to use it in the way he wants.

:-)

Cor
Nov 22 '05 #7
"Cor Ligthert" <no************@planet.nl> schrieb:
'STAThread' is IMO added implicitly, no need to specify it in VB.NET.
It is not even needed to create a Shared Function Main, that is build in
in VB.Net.


A parameterless 'Sub Main' is built in implicitly.
Although I find it foolish to use it in VB.Net is everybody in my opinion
free to use it in the way he wants.


Well, if you want to check the parameters passed to the application, I
strongly vote for using a custom 'Sub Main'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 22 '05 #8
In article <ub*************@TK2MSFTNGP15.phx.gbl>, Herfried K. Wagner [MVP] wrote:
Tom,

"Tom Shelton" <ts******@YOUKNOWTHEDRILLcomcast.net> schrieb:
<STAThread ()> _
Public Shared Function Main (ByVal args() As String) As Integer
End Sub


'STAThread' is IMO added implicitly, no need to specify it in VB.NET.


It maybe - but I tend to do things explicitly. Not always, but often :)

--
Tom Shelton [MVP]
Nov 22 '05 #9
In article <11**********************@z14g2000cwz.googlegroups .com>, Chris Dunaway wrote:
That's the strangest .vb code I have ever seen! :)


Well, he said C# or VB.NET. I usually do C# - so it just comes more
naturally :)
--
Tom Shelton [MVP]
Nov 22 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: ZhangZQ | last post by:
Is it possible to dynamicaly to local and call a function in Win32 dll(not a ..net assembly dll) in C# at run time, for example, a C# program popup a dialogbox to let use input which Win32 dll to...
4
by: ZhangZQ | last post by:
Is it possible to dynamicaly to local and call a function in Win32 dll(not a ..net assembly dll) in C# at run time, for example, a C# program popup a dialogbox to let use input which Win32 dll to...
15
by: Bryan | last post by:
I have a multi-threaded C# console application that uses WMI (System.Management namespace) to make RPC calls to several servers (600+ ) and returns ScheduledJobs. The section of my code that...
4
by: ZhangZQ | last post by:
Is it possible to dynamicaly to local and call a function in Win32 dll(not a ..net assembly dll) in C# at run time, for example, a C# program popup a dialogbox to let use input which Win32 dll to...
8
by: Zytan | last post by:
When using DllImport to import win32 functions that have strings, I know you can use the native c# string type. But, what about a function that expects a string buffer, and writes to it? I've...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.