I recently learned how to use VB.NET to set your program as the default for a chosen extension. You would write code to set a registry value. The problem is, when you open t
The path to the file is passed to your program as a command line parameter. Your program will need to read the command line parameters and react accordingly.
Here is some example code demonstrating how to read the command line parameters:
Sub Main()
Dim s() As String = System.Environment.GetCommandLineArgs()
' write code to open the file here...
Console.WriteLine(s(1))
End Sub
To help with debugging this you can specify command-line arguments in the Visual Studio IDE:
You can also declare your Sub Main
to receive the command line arguments:
Sub Main(Args() As String)
End Sub
The filename is passed to your program by the OS
Sub Main()
Dim s() As String = System.Environment.GetCommandLineArgs()
EndSub
MSDN docs