I have written a sample VB.NET browser app using the MS Explorer COM
component (shdocvw.dll). The app accepts a filename from the
commandline and navigates to it. Browsing works fine.
I included in the app the ability to set it as the default browser. I
suspect that this is where the problem exists. The code I am using is
this:
Dim aKey As Microsoft.Win32.RegistryKey
'Set the htmlfile open command
aKey = Microsoft.Win32.Registry.ClassesRoot.CreateSubKey("\htmlfile\shell\open\command")
aKey.SetValue("", Application.ExecutablePath & " ""%1""")
'Set the opennew command
aKey = Microsoft.Win32.Registry.ClassesRoot.CreateSubKey("\htmlfile\shell\opennew\command")
aKey.SetValue("", """" & Application.ExecutablePath & """ %1")
'Set the secure open command
aKey = Microsoft.Win32.Registry.ClassesRoot.CreateSubKey("\https\shell\open\command")
aKey.SetValue("", Application.ExecutablePath & " ""%1""")
'Set the http open command
aKey = Microsoft.Win32.Registry.ClassesRoot.CreateSubKey("\http\shell\open\command")
aKey.SetValue("", Application.ExecutablePath & " ""%1""")
When I double click on an HTML file, I get an OS messagebox that reads
'Windows cannot find (myfile.html). Make sure you have typed the name
correctly and try again'
However, my sample browser DOES open and it DOES navigate to myfile.html.
If I set IE as my default browser, everything returns to working as normal.
The basic question is this: Do I need to do something differently in
the registry to make this work or does my application need something
else to tell the OS it has found the file and is processing it?
This is a very small VB.NET app that I will gladly e-mail to whomever
takes this question.
Many thanks. |