Esempio n. 1
0
        /// <summary>
        /// Gets the default browser.
        /// </summary>
        /// <returns>The default browser.</returns>
        public static ClientBrowser GetDefaultBrowser()
        {
            if (_defaultBrowser == null)
            {
                string name = null;

                using (RegistryKey userChoice = Registry.CurrentUser.OpenSubKey(@"Software\Clients\StartMenuInternet"))
                    if (userChoice != null)
                    {
                        name = userChoice.GetValue(null) as string;
                    }

                if (name == null)
                {
                    using (RegistryKey userChoice = Registry.LocalMachine.OpenSubKey(@"Software\Clients\StartMenuInternet"))
                        if (userChoice != null)
                        {
                            name = userChoice.GetValue(null) as string;
                        }
                }

                foreach (ClientBrowser browser in GetInstalledBrowsers())
                {
                    if (browser.Name == name)
                    {
                        _defaultBrowser = browser;
                        break;
                    }
                }

                if (_defaultBrowser == null)
                {
                    _defaultBrowser = new ClientBrowser("Default Browser", null, null);
                }
            }

            return(_defaultBrowser);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the default browser.
        /// </summary>
        /// <returns>The default browser.</returns>
        public static ClientBrowser GetDefaultBrowser()
        {
            if (_defaultBrowser == null)
            {
                string name = null;

                using (RegistryKey userChoice = Registry.CurrentUser.OpenSubKey(@"Software\Clients\StartMenuInternet"))
                    if (userChoice != null)
                        name = userChoice.GetValue(null) as string;

                if (name == null)
                {
                    using (RegistryKey userChoice = Registry.LocalMachine.OpenSubKey(@"Software\Clients\StartMenuInternet"))
                        if (userChoice != null)
                            name = userChoice.GetValue(null) as string;
                }

                foreach (ClientBrowser browser in GetInstalledBrowsers())
                {
                    if (browser.Name == name)
                    {
                        _defaultBrowser = browser;
                        break;
                    }
                }

                if (_defaultBrowser == null)
                {
                    _defaultBrowser = new ClientBrowser("Default Browser", null, null);
                }
            }

            return _defaultBrowser;
        }