开发者

How to check for installed browsers using C# for newbies

I am building an app and its a simple one, all I want it to do is display os information in plain english and the architecture as well as check for installed browsers and then I'll add the ability for it to delete cookies and what not.

What Im stuck on is the browser detection part. Can anyone point me to some decent tutorials or how tos? Thanks.

Edit: OK I managed to finally scratch out some working code using the snippet provided by hcb below and the comments from the others (thanks everyone). So far it is doing exactly what I want so I thought id share what I have for those trying to do the same thing:

RegistryKey browserKeys;

        browserKeys = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\Clients\StartMenuInternet");

        if (browserKeys == null)
        {
            browserKeys = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Clients\StartMenuInternet");
        }

        string[] browserNames = browserKeys.GetSubKeyNames();

        foreach (string browser in browserNames)
        {
            using (RegistryKey tempKey = browserKeys.OpenSubKey(browser))
            {
                foreach (string keyName in tempKey.GetValueNames())
                {
                    if (tempKey.GetValue(keyName).ToString() == "Internet Explorer")
                    {
                        internetExplorerButton.Enabled = true;
                        internetExplorerButton.BackgroundImage = Properties.Resources.iExplorer;

                        if (internetExplorerButton.Enabled == true)
                        {
                            Label ieLabel = new Label();
                            ieLabel.Text = "Found!";
                            explorerLable.Text = ieLabel.Text;
                        }
                    }

To my extreme annoyance, I noticed that Google want to install their browser in the Local App Data. I managed to work this out writing the code again separately and checking:

Registry.CurrentUser.OpenSubKey(@"开发者_如何学PythonSOFTWARE\Google\Update\Clients");

Edit2: Checking CurrentUser for Chrome seems to work fine for a few friends so it must be OK.


Like this:

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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜