public static System.Collections.Generic.List <BrowserInfo> GetPreferableBrowser(BrowserRatingCallback_t browserRatingCallback) { System.Collections.Generic.List <BrowserInfo> ls = new System.Collections.Generic.List <BrowserInfo>(); if (System.Environment.OSVersion.Platform == System.PlatformID.Unix) { return(ls); } using (Microsoft.Win32.RegistryKey hklm = Microsoft.Win32.Registry.LocalMachine) { Microsoft.Win32.RegistryKey webClientsRootKey = hklm.OpenSubKey(@"SOFTWARE\Clients\StartMenuInternet"); if (webClientsRootKey != null) { foreach (var subKeyName in webClientsRootKey.GetSubKeyNames()) { if (webClientsRootKey.OpenSubKey(subKeyName) != null) { if (webClientsRootKey.OpenSubKey(subKeyName).OpenSubKey("shell") != null) { if (webClientsRootKey.OpenSubKey(subKeyName).OpenSubKey("shell").OpenSubKey("open") != null) { if (webClientsRootKey.OpenSubKey(subKeyName).OpenSubKey("shell").OpenSubKey("open").OpenSubKey("command") != null) { string commandLineUri = (string)webClientsRootKey.OpenSubKey(subKeyName).OpenSubKey("shell").OpenSubKey("open").OpenSubKey("command").GetValue(null); if (string.IsNullOrEmpty(commandLineUri)) { continue; } commandLineUri = commandLineUri.Trim("\"".ToCharArray()); // viewer.Executable = commandLineUri; string Name = (string)webClientsRootKey.OpenSubKey(subKeyName).GetValue(null); ls.Add(new BrowserInfo() { Name = Name , Path = commandLineUri , Preference = browserRatingCallback(Name) }); } } } } } } } // End Using using (Microsoft.Win32.RegistryKey hklm = Microsoft.Win32.Registry.CurrentUser) { Microsoft.Win32.RegistryKey webClientsRootKey = hklm.OpenSubKey(@"SOFTWARE\Clients\StartMenuInternet"); if (webClientsRootKey != null) { foreach (var subKeyName in webClientsRootKey.GetSubKeyNames()) { if (webClientsRootKey.OpenSubKey(subKeyName) != null) { if (webClientsRootKey.OpenSubKey(subKeyName).OpenSubKey("shell") != null) { if (webClientsRootKey.OpenSubKey(subKeyName).OpenSubKey("shell").OpenSubKey("open") != null) { if (webClientsRootKey.OpenSubKey(subKeyName).OpenSubKey("shell").OpenSubKey("open").OpenSubKey("command") != null) { string commandLineUri = (string)webClientsRootKey.OpenSubKey(subKeyName).OpenSubKey("shell").OpenSubKey("open").OpenSubKey("command").GetValue(null); if (string.IsNullOrEmpty(commandLineUri)) { continue; } commandLineUri = commandLineUri.Trim("\"".ToCharArray()); // viewer.Executable = commandLineUri; string Name = (string)webClientsRootKey.OpenSubKey(subKeyName).GetValue(null); ls.Add(new BrowserInfo() { Name = Name , Path = commandLineUri , Preference = browserRatingCallback(Name) }); } } } } } } } // End Using ls.Sort(); return(ls); } // End Function GetPreferableBrowser
public static System.Collections.Generic.List <BrowserInfo> GetPreferableBrowser(BrowserRatingCallback_t browserRatingCallback) { if (System.Environment.OSVersion.Platform != System.PlatformID.Unix) { return(Win.GetPreferableBrowser(browserRatingCallback)); } // ELSE: Linux / Unix / MacOS if (DistroInfo.PackageManager == DistroInfo.PackageManager_t.dpkg) { return(dpkg.GetInstalledBrowsers(browserRatingCallback)); } return(new System.Collections.Generic.List <BrowserInfo>()); }
} // End Function GetInstalledBrowsers public static System.Collections.Generic.List <BrowserInfo> GetInstalledBrowsers(BrowserRatingCallback_t browserRatingCallback) { System.Collections.Generic.List <BrowserInfo> ls = new System.Collections.Generic.List <BrowserInfo>(); System.Collections.Generic.List <string> packageList = GetPossibleBrowsers(); foreach (string packageName in packageList) { if (IsPackageInstalled(packageName)) { int sort = browserRatingCallback(packageName); ls.Add(new BrowserInfo() { Name = packageName , Path = GetExecutable(packageName) , Preference = sort }); } // End if (isPackageInstalled(packageName)) } // Next packageName ls.Sort(); return(ls); } // End Function GetInstalledBrowsers