Link to home
Start Free TrialLog in
Avatar of riyasjef
riyasjef

asked on

How to Set Command line arguments for a VB application

Hi
      I developed a Vb aplication that can open particular files ( say with extension  xyz ) . User can open such files from Application GUI. But i would like to enable the application when such files are double clicked. Also  How can i enable command line argument property for my application. That is if my application name is  MyApp.exe , i need to use the following  command line to start application for the file Test.xyz


MyApp "c:\Sample\Test.xyz"

so that my application starts with the file Test.xyz opened in it as if i tried to open it from Application GUI.

Thanks in Advance
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
and you shoud write the code above in your Startup Object (usually it's a Form Object, or write it to Sub Main() if your app start with Main() Sub)
To create a file association with your application, you must make a registry entry.  Here is a code example of how to do this:

Creating a Visual Basic File Association
http://vbnet.mvps.org/index.html?code/reg/association.htm

Also, to process command line args, use the Command function example on this page from MSDN:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbenlr98/html/vafctCommand.asp