[Help] Finding user's default Web Browser name.

Posts 1–10 of 10 · Page 1 of 1
[Help] Finding user's default Web Browser name.
How to get name of users Internet browser?
Someone posted a tut 1 day ago, search button
searched everywhere cant find it...
Snippets Vault?
yes but i cant find it
i want this:
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.
Quote Originally Posted by Erinador View Post
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]

thanks jason it worked!
/solved
Quote Originally Posted by hitmen69 View Post
thanks jason it worked!
/solved
Of course it worked, I wrote it

Marked solved
Posts 1–10 of 10 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

None

Talk with us