static WebBrowserInfo DetectMaxthon3() { //maxthon3? WebBrowserInfo maxthon = null; try { var mkey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Maxthon3", false); if (mkey != null) { var folder = mkey.GetValue("Folder") as string; if (!string.IsNullOrEmpty(folder)) { var path = Path.Combine(folder, "bin", "maxthon.exe"); if (File.Exists(path)) { maxthon = new WebBrowserInfo { Name = "傲游浏览器", Path = path } } ; } mkey.Close(); } } catch (Exception) { } return(maxthon); }
static WebBrowserInfo DetectFirefox() { RegistryKey key = null; WebBrowserInfo firefox = null; try { key = Registry.CurrentUser.OpenSubKey(@"Software\Mozilla\Mozilla Firefox"); if (key != null) { var versions = key.GetSubKeyNames(); var firefoxPath = versions.Select(s => { try { return(key.OpenSubKey(s + "\\Main", false)); } catch (Exception) { return(null); } }).ExceptNull().Select(s => (s.GetValue("PathToExe") ?? "").ToString()).FirstOrDefault(s => !string.IsNullOrEmpty(s) && File.Exists(s)); if (firefoxPath != null) { firefox = new WebBrowserInfo { Name = "Firefox", Path = firefoxPath }; } } } catch (Exception) { } finally { if (key != null) { key.Close(); } key = null; } return(firefox); }