469,903 Members | 2,234 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

Command Line Args

I have a file type that is going to be associated with my
visual basic application and i want the user to be able
to double click on a file of said type and have it launch
the program and load the file. I know there are certain
keys in the registry that i have to create and/or edit.
I have located them, namely HKEY_CLASSES_ROOT\.stdf and
HKEY_CLASSES_ROOT\stdf_auto_file\shell\open\comman d

The default value for that last key is the path to my
application followed by "%1". I thought that this would
take the file that was double clicked and pass it to my
program but on inspection of the
Environment.GetCommandLineArgs() I found that only the
path to the calling program is getting passed.

Is there a problem with my registry keys or my visual
basic program that needs to be addressed. Any help is
greatly appreciated.
Thanks
-Paul
Nov 20 '05 #1
2 3769
Hello,

You may want to try Microsoft.VisualBasic.Command() function. Here is what
Help file says:

Returns the argument portion of the command line used to launch Visual Basic
or an executable program developed with Visual Basic.

Public Function Command() As String
Remarks
For applications developed with Visual Basic and compiled to an .exe file,
the Command function returns any arguments that appear after the name of the
application on the command line, as in this example:

MyApp cmdlineargs
Example
This example uses the Command function to get the command-line arguments in
a function that returns them in an object containing an array.

Function GetCommandLineArgs() As String()
' Declare variables.
Dim separators As String = " "
Dim commands As String = Microsoft.VisualBasic.Command()
Dim args() As String = commands.Split(separators.ToCharArray)
Return args
End Function

You may add your own filetypes in setup project configuration.
Hope it helps :-)

sincerely,
--
Sebastian Zaklada
Skilled Software
http://www.skilledsoftware.com
************************************
SQL Source Control 2003 - for
SQL Server Source Safe integration
and custom databases documentation

"paul" <an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl...
I have a file type that is going to be associated with my
visual basic application and i want the user to be able
to double click on a file of said type and have it launch
the program and load the file. I know there are certain
keys in the registry that i have to create and/or edit.
I have located them, namely HKEY_CLASSES_ROOT\.stdf and
HKEY_CLASSES_ROOT\stdf_auto_file\shell\open\comman d

The default value for that last key is the path to my
application followed by "%1". I thought that this would
take the file that was double clicked and pass it to my
program but on inspection of the
Environment.GetCommandLineArgs() I found that only the
path to the calling program is getting passed.

Is there a problem with my registry keys or my visual
basic program that needs to be addressed. Any help is
greatly appreciated.
Thanks
-Paul

Nov 20 '05 #2
"paul" <an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl...
I have a file type ... to be able to double click on a file of said
type and have it launch the program and load the file.


Code you application to start with a Sub Main that looks like this:

Sub Main( ByVal saArguments() as String )
' Load and Run() main form in here

With the Registry settings you describe, double-clicking on a file
should fire up your program and deliver [the path and name of]
the file into saArguments( 0 ) - all being well.

HTH,
Phill W.
Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Manlio Perillo | last post: by
reply views Thread by andrea valle | last post: by
4 posts views Thread by Milan | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.