@Karlo Vragotuk , Welcome to Microsoft Q&A, based on my research, I find we could use registry to get installed apps. But it is not easy to get every icons for me. Because many apps does not have their own icons.
I make the following code to show all installed apps in the listbox and show part of icons in the listview.
Icon ProductIcon;
ImageList imageListLarge = new ImageList();
private void button1_Click(object sender, EventArgs e)
{
string registry_key = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
int i = 0;
using (Microsoft.Win32.RegistryKey key = Registry.LocalMachine.OpenSubKey(registry_key))
{
foreach (string subkey_name in key.GetSubKeyNames())
{
using (RegistryKey subkey = key.OpenSubKey(subkey_name))
{
if (subkey.GetValue("DisplayName") != null)
{
//Console.WriteLine(subkey.GetValue("DisplayName"));
listBox1.Items.Add(subkey.GetValue("DisplayName").ToString());
if (subkey.GetValue("DisplayIcon") != null)
{
Console.WriteLine(subkey.GetValue("DisplayIcon").ToString());
if (File.Exists(subkey.GetValue("DisplayIcon").ToString()))
{
ProductIcon = Icon.ExtractAssociatedIcon(subkey.GetValue("DisplayIcon").ToString());
ListViewItem item1 = new ListViewItem();
item1.SubItems.Add("item1");
item1.SubItems.Add("item2");
item1.ImageIndex = i;
listView1.Items.Add(item1);
imageListLarge.Images.Add(ProductIcon);
i++;
}
else if(subkey.GetValue("DisplayIcon").ToString().EndsWith("0"))
{
string s = subkey.GetValue("DisplayIcon").ToString().Replace(",0", "");
ProductIcon = Icon.ExtractAssociatedIcon(s.Trim());
ListViewItem item1 = new ListViewItem();
item1.SubItems.Add("item1");
item1.SubItems.Add("item2");
item1.ImageIndex = i;
listView1.Items.Add(item1);
imageListLarge.Images.Add(ProductIcon);
i++;
}
}
}
}
}
}
listView1.SmallImageList = imageListLarge;
}
private void Form1_Load(object sender, EventArgs e)
{
listView1.View = View.SmallIcon;
// Allow the user to edit item text.
listView1.LabelEdit = true;
// Allow the user to rearrange columns.
listView1.AllowColumnReorder = true;
// Display check boxes.
listView1.CheckBoxes = true;
// Select the item and subitems when selection is made.
listView1.FullRowSelect = true;
// Display grid lines.
listView1.GridLines = true;
// Sort the items in the list in ascending order.
listView1.Sorting = SortOrder.Ascending;
}
Result:
Hope this could help you.
Best regards,
Jack
If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.