C#:如何让安装程序完全一样的控制面板程序和功能?安装程序、面板、功能、程序

2023-09-02 21:35:52 作者:不适合说爱的年纪

我看了很多获取节目信息。无算法并做我想做的。我需要安装的程序的完全的就像在控制面板中。

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.

所以我用:

WMI 的Win32_Product 类。只显示MSI安装程序。 注册表项。 HKLM SOFTWARE 微软的Windows CurrentVersion 卸载。此外,某些程序不能在控制面板中显示,而不是在此注册表节点显示在控制面板中的一些程序。 WMI Win32_Product class. It shows only msi installed programs. Registry keys. HKLMSOFTWAREMicrosoftWindowsCurrentVersionUninstall. 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:是的,我用64位,我知道有另一个节点的64位安装的程序HKLM SOFTWARE Wow6432Node 微软的Windows CurrentVersion 卸载,但下面的code列举twise HKLM SOFTWARE Wow6432Node 微软的Windows CurrentVersion 卸载部分,奇怪...

UPD1:yes, i use 64 bit, i know there is another node for 64bit installed programs "HKLMSOFTWAREWow6432NodeMicrosoftWindowsCurrentVersionUninstall" but the following code enumerates twise HKLMSOFTWAREWow6432NodeMicrosoftWindowsCurrentVersionUninstall section, strange...

var programs = new List();
    string registry_key = @"SOFTWAREMicrosoftWindowsCurrentVersionUninstall";
    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);
                }
            }
        }
    }

推荐答案

好gyus,我写的可以不修补程序和更新获取安装从注册表的程序类。它仍然是不完全就像在控制面板上,但几乎。我希望这可以帮助其他人。

Ok gyus, i wrote class that can get installed programs from registry without hotfixes and updates. It is still not exactly like in control panel but almost. I hope this helps anyone else.


public static class InstalledPrograms
{
    const string registry_key = @"SOFTWAREMicrosoftWindowsCurrentVersionUninstall";