Finding All Installed Browsers in Windows XP and Vista – beware 64bit!

April 3 2009

In the application I’ve been working on, I needed to find all browsers that are installed on a user’s machine. The best way to go about this is to look in the registry under HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet. This is where browser manufacturers are told to put their information, per this MSDN article.  But here’s a gotcha I hit: on 64bit, the keys get written to HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Clients\StartMenuInternet.

No big deal: just need to check that key first.

So, here’s the code I ended up writing to get the name, file path and icon for the browsers installed on a user’s machine.  (Note that the Browser object is my own class.)

RegistryKey browserKeys;
//on 64bit the browsers are in a different location
browserKeys = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\Clients\StartMenuInternet");
if (browserKeys == null)
    browserKeys = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Clients\StartMenuInternet");

string[] browserNames = browserKeys.GetSubKeyNames();

for (int i = 0;i<browserNames.Length;i++)
{
    Browser browser = new Browser();
    RegistryKey browserKey = browserKeys.OpenSubKey(browserNames[i]);
    browser.Name = (string) browserKey.GetValue(null);
    RegistryKey browserKeyPath = browserKey.OpenSubKey(@"shell\open\command");
    browser.Path = (string)browserKeyPath.GetValue(null);
    RegistryKey browserIconPath = browserKey.OpenSubKey(@"DefaultIcon");
    browser.IconPath = (string)browserIconPath.GetValue(null);
    this.Add(browser);
}

Comments (2) -

1/6/2012 9:08:06 AM #

Rockey Nehwani

Is there a equivalent of this for Mac? And can we use this logic on a web page?

Rockey Nehwani

1/6/2012 9:08:52 AM #

Rockey Nehwani

Is there a equivalent of this for Mac? And can we use this logic on a web page?

Rockey Nehwani

Add comment

biuquote
  • Comment
  • Preview
Loading

VSAchievements
Visual Studio Achievements
Karsten Januszewski (207 Points)