Пример #1
0
        public List<BrowserInfo> GetBrowsersFromClients()
        {
            var browsers = new List<BrowserInfo>();

            const string regKeyPfad = @"Software\Clients\StartMenuInternet\";
            var regKey = Registry.LocalMachine.OpenSubKey(regKeyPfad);

            if (regKey != null)
            {
                var installedBrowsers = regKey.GetSubKeyNames().ToList();

                foreach (var installedBrowser in installedBrowsers)
                {
                    if (installedBrowser != "IEXPLORE.EXE")
                    {
                        var associations = installedBrowser + @"\Capabilities\URLAssociations\";
                        var regkeyAssociations = Registry.LocalMachine.OpenSubKey(regKeyPfad + associations);

                        var browser = new BrowserInfo();
                        GetName(installedBrowser, ref browser);
                        browser.Source = GetIconFile(installedBrowser);
                        browser.UrlAssociationFTP = regkeyAssociations.GetValue("ftp") != null
                                                        ? regkeyAssociations.GetValue("ftp").ToString()
                                                        : null ;
                        browser.UrlAssociationHTTP = regkeyAssociations.GetValue("http") != null
                                                        ? regkeyAssociations.GetValue("http").ToString()
                                                        : null;
                        browser.UrlAssociationHTTPS = regkeyAssociations.GetValue("https") != null
                                                        ? regkeyAssociations.GetValue("https").ToString()
                                                        : null;

                        browsers.Add(browser);
                    }
                    else
                    {
                        var browser = new BrowserInfo();
                        GetName(installedBrowser, ref browser);
                        browser.Source = GetIconFile(installedBrowser);
                        browser.UrlAssociationFTP = "IE.HTTP";
                        browser.UrlAssociationHTTP = "IE.HTTP";
                        browser.UrlAssociationHTTPS = "IE.HTTPs";

                        browsers.Add(browser);
                    }

                }
            }
            return browsers;
        }
Пример #2
0
 private void GetName(string installedBrowser, ref BrowserInfo browser)
 {
     switch (installedBrowser)
     {
         case "FIREFOX.EXE":
             browser.Name = BrowserEnum.FireFox.ToString();
             browser.IsActive = IsBrowserActive(BrowserEnum.FireFox);
             break;
         case "Google Chrome":
             browser.Name = BrowserEnum.Chrome.ToString();
             browser.IsActive = IsBrowserActive(BrowserEnum.Chrome);
             break;
         case "IEXPLORE.EXE":
             browser.Name = BrowserEnum.InternetExplorer.ToString();
             browser.IsActive = IsBrowserActive(BrowserEnum.InternetExplorer);
             break;
         case "Opera":
             browser.Name = BrowserEnum.Opera.ToString();
             browser.IsActive = IsBrowserActive(BrowserEnum.Opera);
             break;
         case "Safari.exe":
             browser.Name = BrowserEnum.Safari.ToString();
             browser.IsActive = IsBrowserActive(BrowserEnum.Safari);
             break;
         default:
             browser.Name = installedBrowser;
             browser.IsActive = false;
             break;
     }
 }