Created
August 6, 2015 05:01
-
-
Save kakopappa/f637bea7195b112491d5 to your computer and use it in GitHub Desktop.
Get list of install programs with icons in Windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppsUtil | |
{ | |
public static List<InstalledApp> GetInstalledApps() | |
{ | |
List<InstalledApp> map = new List<InstalledApp>(); | |
string InstallerKey = @"Installer\Products"; | |
using (RegistryKey installkeys = Registry.ClassesRoot.OpenSubKey(InstallerKey)) | |
{ | |
foreach (string name in installkeys.GetSubKeyNames()) | |
{ | |
using (RegistryKey product = installkeys.OpenSubKey(name)) | |
{ | |
string productName = product.GetValue("ProductName").ToString(); | |
string productIcon = null; | |
if (product.GetValue("ProductIcon") != null) { | |
productIcon = product.GetValue("ProductIcon").ToString(); | |
} | |
if (productName != null && productIcon != null) | |
{ | |
Icon icon = Icon.ExtractAssociatedIcon(productIcon); | |
map.Add(new InstalledApp() { Photo = icon.ToBitmap(), Name = productName }); | |
} | |
} | |
} | |
} | |
return map; | |
} | |
} | |
public class InstalledApp { | |
public string Name { get; set; } | |
public Image Photo { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment