|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to get cmdArgs in Windows Application (vs2005) ?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 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 Theres no reason why it should. You can designate your Main method as being> 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. 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 <RBarryYo***@gmail.com> wrote in message Show quoteHide quote news:1138570439.848157.286460@z14g2000cwz.googlegroups.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 > <RBarryYo***@gmail.com> schrieb:
> 1) Access to the command-line arguments (cmdArgs()) that started my 'Environment.GetCommandLineArgs'.> 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. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Thanks, Herfried. I have since discovered [My.Application.Commands]
which works also. -- RBarryYoung |
|||||||||||||||||||||||