By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,685 Members | 1,326 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,685 IT Pros & Developers. It's quick & easy.

How to: Launch application AND open the "triggering" file

P: n/a
Hi, I need some help. Hopefully this is trivial!

I have created a special file type for my application. I can easily
associate the app with the file type manually and I have even seen som code
to do this as well. (MSDN - 185453)

However, once the app is launched after double-clicking on the file,
how can I identify which file was selected, i.e. triggered the launch.

Pls point me to the right direction for search!
Thanks,
Bob



Nov 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
In article <#h**************@TK2MSFTNGP10.phx.gbl>, Bob Lidgard wrote:
Hi, I need some help. Hopefully this is trivial!

I have created a special file type for my application. I can easily
associate the app with the file type manually and I have even seen som code
to do this as well. (MSDN - 185453)

However, once the app is launched after double-clicking on the file,
how can I identify which file was selected, i.e. triggered the launch.

Pls point me to the right direction for search!
Thanks,
Bob


Bob,

I believe the file path is passed in as a command line argument. So,
just check the command line - either by including it in your main
declaration or use System.Environment.CommandLine or
System.Environment.GetCommandLineArgs to retrieve the command line...

' main method
Public Sub Main(ByVal Args() As String)
....

End Sub
' System.Envrionment.CommandLine

Dim cmdLine As String = System.Envrionment.CommandLine
'System.Environment.GetCommandLineArgs()

Dim cmdLine() As String = System.Environment.GetCommandLineArgs()

HTH,
Tom Shelton
Nov 20 '05 #2

P: n/a
* "Bob Lidgard" <bl******@hotmail.com> scripsit:
Hi, I need some help. Hopefully this is trivial!

I have created a special file type for my application. I can easily
associate the app with the file type manually and I have even seen som code
to do this as well. (MSDN - 185453)

However, once the app is launched after double-clicking on the file,
how can I identify which file was selected, i.e. triggered the launch.

Pls point me to the right direction for search!


\\\
Public Sub Main(ByVal astrCmdLineArgs() As String)
Dim i As Integer
For i = 0 To astrCmdLineArgs.Length - 1
Console.WriteLine(astrCmdLineArgs(i))
Next i
End Sub
///

Set the project's startup object to "Sub Main".

--
Herfried K. Wagner
MVP VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #3

P: n/a
Hi Bob,

If you've tried to get the file name from the command line args and it's
still not working, check that the command in the file association has %1 as
its arguments.

Regards,
Fergus
Nov 20 '05 #4

P: n/a
Dear all,

Many thanks for your swift assistance!

Great!

Bob

"Bob Lidgard" <bl******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi, I need some help. Hopefully this is trivial!

I have created a special file type for my application. I can easily
associate the app with the file type manually and I have even seen som code to do this as well. (MSDN - 185453)

However, once the app is launched after double-clicking on the file,
how can I identify which file was selected, i.e. triggered the launch.

Pls point me to the right direction for search!
Thanks,
Bob


Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.