/// <summary> /// Returns the display names of all installed Microsoft Visual C++ redistributable packages. /// </summary> /// <param name="refresh"> /// true to refresh all names; otherwise, false to get the cached names from previous call. /// <para> /// Please note that this parameter is always true if this function has never been called /// before. /// </para> /// </param> public static string[] GetDisplayNames(bool refresh = false) { try { if (!refresh && _displayNames != null) { return(_displayNames); } var comparer = new Comparison.AlphanumericComparer(); var entries = new[] { "DisplayName", "ProductName" }; var names = Reg.GetSubKeyTree(Registry.LocalMachine, "SOFTWARE\\Classes\\Installer", 3000) .SelectMany(x => entries, (x, y) => Reg.ReadString(Registry.LocalMachine, x, y)) .Where(x => x.StartsWithEx("Microsoft Visual C++")) .OrderBy(x => x, comparer); _displayNames = names.ToArray(); return(_displayNames); } catch (Exception ex) when(ex.IsCaught()) { Log.Write(ex); return(null); } }