I have this code that will grab the names, but how do i get each program’s icon?
string SoftwareKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Products";
RegistryKey rk = default(RegistryKey);
rk = Registry.LocalMachine.OpenSubKey(SoftwareKey);
string sname = string.Empty;
foreach (string skname in rk.GetSubKeyNames())
{
try
{
sname = Registry.LocalMachine.OpenSubKey(SoftwareKey).OpenSubKey(skname).OpenSubKey("InstallProperties").GetValue("DisplayName").ToString();
string Inst1 = Registry.LocalMachine.OpenSubKey(SoftwareKey).OpenSubKey(skname).OpenSubKey("InstallProperties").GetValue("InstallLocation").ToString();
int n = dataGridView1.Rows.Add();
dataGridView1.Rows[n].Cells[2].Value = sname;
dataGridView1.Rows[n].Cells[3].Value = Inst1;
}
catch (Exception ex)
{
//MessageBox.Show(ex.Message);
}
}
I’m not aware that
InstallPropertieswill give you the installed executable (as indeed an installer could install multiple executable files).If you have a means to determine the correct executable (including perhaps enumerating the .exe files in
InstallLocation), you could then grab the default icon from that .exe.For details, see
Get File Icon used by Shell
UPDATE
The following code is untested but should get you pretty close: