473,549 Members | 2,588 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 "Applicatio n 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 3724
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.Ena bleVisualStyles ()
Application.DoE vents()
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*********@gm ail.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.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 "Applicatio n 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*********@gm ail.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 "Applicatio n 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.Ge tCommandLineArg s'.

--
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
2828
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; std::wcout<<L" Argument Count "<<argc-1<<std::endl;
1
1038
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 specified a server path on a file server where I would like to publish new version when it becomes available so that all clients running this windows...
2
1279
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 get the "This application has failed to start because the application configuration is incorrect" error. Is there a way to make the Windows Forms...
1
1436
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 setting ACL:s. I thought I had completed my application since it seemed to work fine setting the ACL:s the way I wanted to.
0
1013
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 by creating a bmp file in paint, setting it as a background & and also setting FormBorderStyle to None BackgroundImage to my bmp...
2
1350
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 have to specify version 6.0.0.0 of Microsoft.Windows.Common-Controls as a depency in a manifest file for the exe. If you create a similar C#...
3
4607
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 application for windows embedded ce 6.0. I currently have the ability to create an application for windows ce 5.0. The device I am developing for is running...
1
2362
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 result we have re-built the application in VS2005 with .NET 2.0. We can deploy the application to the mobile device OK via active-synch. ...
5
1193
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 etc....and the simple things, like the 'About' option, opens another form.... Well here is the problem (which has me stumped).... My VB6...
0
7532
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7461
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7491
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7823
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6055
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5381
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5101
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3509
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
776
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.