I read a lot of information of getting programs. None of algorithms did do what I want. I need to get installed programs exactly like in control panel.
So I used:
- WMI
Win32_Product
class. It shows only msi installed programs. - Registry keys.
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
. Again, some programs are not displayed in control panel, some programs displayed in control panel not in this registry node.
So, is there anyone in this world, who knew which algorithm use control panel to display installed programs?
UPD1:yes, i use 64 bit, i know there is another node for 64bit installed programs "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" but the following code enumerates twise HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall section, strange...
var programs = new List(); string registry_key = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"; using (Microsoft.Win32.RegistryKey key = Registry.LocalMachine.OpenSubKey(registry_key)) { foreach (string subkey_name in key.GetSubKeyNames()) { using (RegistryKey subkey = key.OpenSubKey(subkey_name)) { var name = (string)subkey.GetValue("DisplayName"); if(!string.IsNullOrEmpty(name)) { programs.Add(name); } } } } registry_key = @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"; using (Microsoft.Win32.RegistryKey key = Registry.LocalMachine.OpenSubKey(registry_key)) { foreach (string subkey_name in key.GetSubKeyNames()) { using (RegistryKey subkey = key.OpenSubKey(subkey_name)) { var name = (string)subkey.GetValue("DisplayName"); if (!string.IsNullOrEmpty(name)) { programs.Add(name); } } } } foreach (var program in programs.OrderBy(x => x)) { Console.WriteLine(program); }
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
should do it. Can you give an example of a program that appear in Control Panel but not in this reg key? – EustaciaRegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)
instead ofRegistry.LocalMachine
to get the entries from the 64-bit key. – Galvano