public InstallationData(string exePath, InstallationLevel level, int iconIndex, string name, string version) { string location = Path.GetDirectoryName(exePath); Distribution = DistributionType.Canary; Architecture = ProcessUtility.GetMachineType(exePath); Level = level; InstallationPath = new FullPath(location); if (InstallationPath.HasComponent("Chrome SxS")) { Distribution = DistributionType.Canary; } else if (InstallationPath.HasComponent("Chrome")) { Distribution = DistributionType.Chrome; } else { Distribution = DistributionType.Chromium; } IconIndex = iconIndex; Name = name; Version = version; }
public static string LevelString(this InstallationLevel level) { if (level == InstallationLevel.System) { return("System-level"); } else { return("User-level"); } }
public InstallationData(string exePath, InstallationLevel level, int iconIndex, string name, string version) { string location = Path.GetDirectoryName(exePath); Distribution = DistributionType.Canary; Architecture = ProcessUtility.GetMachineType(exePath); Level = level; InstallationPath = new FullPath(location); if (InstallationPath.HasComponent("Chrome SxS")) Distribution = DistributionType.Canary; else if (InstallationPath.HasComponent("Chrome")) Distribution = DistributionType.Chrome; else Distribution = DistributionType.Chromium; IconIndex = iconIndex; Name = name; Version = version; }
private IEnumerable <InstallationData> Enumerate(InstallationLevel level) { List <InstallationData> results = new List <InstallationData>(); RegistryHive hive = (level == InstallationLevel.User) ? RegistryHive.CurrentUser : RegistryHive.LocalMachine; using (RegistryKey baseKey = RegistryKey.OpenBaseKey(hive, RegistryView.Default)) using (RegistryKey uninstallKey = baseKey.OpenSubKey(kUninstallSubKey)) { foreach (string subkeyName in uninstallKey.GetSubKeyNames()) { using (RegistryKey subkey = uninstallKey.OpenSubKey(subkeyName)) { string exePath = GetChromeExePath(subkey); if (string.IsNullOrEmpty(exePath)) { continue; } int iconIndex = 0; string iconString = (string)subkey.GetValue("DisplayIcon"); if (iconString != null) { int index = iconString.LastIndexOf(','); string indexString = iconString.Substring(index + 1); iconIndex = int.TryParse(indexString, out index) ? index : 0; } string name = (string)subkey.GetValue("DisplayName"); string version = (string)subkey.GetValue("DisplayVersion"); results.Add(new InstallationData(exePath, level, iconIndex, name, version)); } } } return(results); }