473,385 Members | 1,888 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,385 software developers and data experts.

How to get cmdArgs in Windows Application (vs2005) ?

How can I get the following two features in the same program in
VS2005?:

1) Access to the command-line arguments (cmdArgs()) that started my
App.

2) Shutdown Mode = "When last Form exits".

The first feature requires a "Sub Main(cmdArgs())", however my app
exits when the Main Sub exits, EVEN if I have an open & running Form.

The second feature seems to require that I specify my project type as
"Windows Applicaiton" and enable "Application Framework" (is this
documented anywhere?). BUT, the Windows Application Framework has it's
own MAin Sub and apparently won't call mine. Even if it did, I doubt
that it would be nice and pass cmdArgs() to me.

Since this is the way that all VB apps used to work, I have to
believe that there is a way to do it. However, I sure cannot find it.

Help, please.

-- Barry Young

Jan 29 '06 #1
3 3716
All applications require an entry point. In .Net executables that entry
point is the Main method. To get access to any arguments supplied via the
command line you simply iterate the args array of type string. This of
course requires that know that arg(0) means something specific, args(1)
means something else.... so it is highly application/order specific.
BUT, the Windows Application Framework has it's
own MAin Sub and apparently won't call mine. Even if it did, I doubt
that it would be nice and pass cmdArgs() to me.
Theres no reason why it should. You can designate your Main method as being
the main method for the application in project properties > Right Mouse
Click on your project in Solution Explorer. However beyond that there is no
reason why the VS designated main method cannot simply call your main method
and supply it the arguments from the command line.

If your application is exiting upon completion of Sub Main then you have not
started a messaging loop to for your starting/main form. You do this as
below via application.run:

Private Sub BootApplication()
Application.EnableVisualStyles()
Application.DoEvents()
Application.Run(New frmMain)
End Sub

You can google what the other methods mean. Note that application.run opens
a message loop and is different form creating an application domain in which
to run the application.

If you put code below application.run it will not be executed until
application.run returns. Application.run will not return until the main
application form is closed. This should answer your second question.

tm
<RB*********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com... How can I get the following two features in the same program in
VS2005?:

1) Access to the command-line arguments (cmdArgs()) that started my
App.

2) Shutdown Mode = "When last Form exits".

The first feature requires a "Sub Main(cmdArgs())", however my app
exits when the Main Sub exits, EVEN if I have an open & running Form.

The second feature seems to require that I specify my project type as
"Windows Applicaiton" and enable "Application Framework" (is this
documented anywhere?). BUT, the Windows Application Framework has it's
own MAin Sub and apparently won't call mine. Even if it did, I doubt
that it would be nice and pass cmdArgs() to me.

Since this is the way that all VB apps used to work, I have to
believe that there is a way to do it. However, I sure cannot find it.

Help, please.

-- Barry Young

Jan 29 '06 #2
<RB*********@gmail.com> schrieb:
1) Access to the command-line arguments (cmdArgs()) that started my
App.
[...]
The second feature seems to require that I specify my project type as
"Windows Applicaiton" and enable "Application Framework" (is this
documented anywhere?). BUT, the Windows Application Framework has it's
own MAin Sub and apparently won't call mine. Even if it did, I doubt
that it would be nice and pass cmdArgs() to me.


'Environment.GetCommandLineArgs'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Jan 29 '06 #3
Thanks, Herfried. I have since discovered [My.Application.Commands]
which works also.

-- RBarryYoung

Jan 30 '06 #4

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

Similar topics

9
by: Vinu | last post by:
Hai when i compile the cpp file(cmdargs.cpp) i attached the output below the program int main(int argc, wchar_t* argv) { std::wcout<<L"Name of the Program is "<<*argv<<std::endl;...
1
by: Brano | last post by:
Hi all, I am new to VS 2005 I have a windows application in VS2005 and I clicked Publish and it gave me several options one of them is where will this application look for updates. I have...
2
by: Jakanapes | last post by:
Hi all, I'm new to VS2005 and I'm having trouble getting my executable to run on another machine. It's a Windows Forms app. and both PCs have the .NET framework installed. However, I still...
1
by: Marcus | last post by:
Hi, My Windows account do not have administrator priviliges anymore even though the user account window accessible from the control panel claims I do. I did my first time programming with...
0
by: zyberboy | last post by:
I am a beginner in programming(c#),and this is my first post in this forum. I want to know how to create custom shaped windows form in vs2005 express edition. I was able to create a oval shaped form...
2
by: david.topham | last post by:
Hi Can anyone help me with a project upgrade issue?: If you creeate a C# Windows application in VS 2003, then by default the forms do not have the XP look common controls. To get them, you...
3
by: =?Utf-8?B?S2ltYXJrTmF0?= | last post by:
What do i need to download to add windows ce 6.0 templates in visual studio 2005? I have been spending the last couple of days trying to figure out how to add the capability to create an...
1
by: Sharky Ward | last post by:
We have a C# windows mobile form application designed for PockedtPC 2003 developed in VS2003.NET with .NET 1.0/1.1. Some of the mobile devices have been replaced with Windows Mobile 5.0. As a...
5
by: Kardon Coupé | last post by:
Dear All, I'm bemused, I'm moving an application I've written from VB6 into VS2005, and I'm getting all the fundamentals over before I delve into the hard part, like getting the forms layout...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

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.