Meh I can't guarantee this will work as I only did a quick test on my own computer before posting.
[highlight=vb.net]
Private Function getDefaultBrowser() As String
Dim retVal As String = String.Empty
Using basekey As Microsoft.Win32.RegistryKey = My.Computer.Registry.ClassesRoot.OpenSubKey(".html ", False)
retVal = basekey.GetValue("").ToString.Replace("HTML", "")
End Using
Return retVal
End Function
[/highlight]
Yeah, try that out.
You could check the registry to see what the user has associated with the extension .html and the like. Ofcourse this isn't the ideal way considering some people have it associated with other programs such as Dreamweaver.
Gl though.
Originally Posted by Erinador
You could check the registry to see what the user has associated with the extension .html and the like. Ofcourse this isn't the ideal way considering some people have it associated with other programs such as Dreamweaver.
Gl though.
I found a more ...foolproof... way, although this is just Vista I'm testing on, and as usual it seems like the black sheep with fucking everything.
It's gunna get rather messy
[highlight=vb.net]
Private Function getDefaultBrowser() As String
Dim retVal As String = String.Empty
Using basekey As Microsoft.Win32.RegistryKey = My.Computer.Registry.CurrentUser.OpenSubKey("Softw are\Microsoft\Windows\Shell\Associations\UrlAssoci ations\http\UserChoice", False)
retVal = basekey.GetValue("Progid").ToString.Replace("HTML" , "")
End Using
Return retVal
End Function
[/highlight]
Although apparently in xp you can get the default browser like so: (haven't tested, don't have XP)
[highlight=vb.net]
Private Function getDefaultBrowser() As String
Dim retVal As String = String.Empty
Using basekey As Microsoft.Win32.RegistryKey = My.Computer.Registry.LocalMachine.OpenSubKey("SOFT WARE\Clients\StartMenuInternet")
Using defaultKey As Microsoft.Win32.RegistryKey = basekey.OpenSubKey(basekey.GetSubKeyNames()(0))
retVal = defaultKey.GetValue("").ToString
End Using
End Using
Return retVal
End Function
[/highlight]
For me that still returns "Internet Explorer" but yeah, if you have XP give it a shot.
EDIT: I am the master:
[highlight=vb.net]
Private Function getDefaultBrowser() As String
Dim retVal As String = String.Empty
Using baseKey As Microsoft.Win32.RegistryKey = My.Computer.Registry.CurrentUser.OpenSubKey("Softw are\Clients\StartmenuInternet")
Dim baseName As String = baseKey.GetValue("").ToString
Dim subKey As String = "SOFTWARE\" & IIf(Environment.GetEnvironmentVariable("PROCESSOR_ ARCHITECTURE") = "AMD64", "Wow6432Node\", "") & "Clients\StartMenuInternet\" & baseName
Using browserKey As Microsoft.Win32.RegistryKey = My.Computer.Registry.LocalMachine.OpenSubKey(subKe y)
retVal = browserKey.GetValue("").ToString
End Using
End Using
Return retVal
End Function
[/highlight]