473,396 Members | 2,013 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,396 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 21 '05 #1
9 1222
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 21 '05 #2
Andre,

You can pass the information using an array of strings

I hope this helps?

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

Nov 21 '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 21 '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 21 '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 21 '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 21 '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 21 '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 21 '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...
9
by: André | last post by:
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...
7
by: Zlatko Matiæ | last post by:
Let's assume that we have a database on some SQL server (let it be MS SQL Server) and that we want to execute some parameterized query as a pass.through query. How can we pass parameters to the...
0
by: Zlatko Matiæ | last post by:
Hi everybody! Recently I was struggling with client/server issues in MS Access/PostgreSQL combination. Although Access is intuitive and easy to use desktop database solution, many problems...
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...
3
by: Michael | last post by:
Hi all, I'm trying to figure out how to use setupapi.dll in C#, specifically the SetupDiCallClassInstaller function. I'm trying to develop a test suite which tests drivers and part of this...
8
by: Claus | last post by:
Hi all, I am new to C#, .NET and Visual Studio but I have been coding professionally for more than 10 years, so I am not a complete newbe :-) At my work we are now in the process of switching...
11
by: Zytan | last post by:
Most code on the net is wrong. This is SendMessage(): LRESULT SendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); All of those parameters are 32/64-bit in size depending on the...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.