C#:如何让安装程序完全一样的控制面板程序和功能? [英] C#: How to get installing programs exactly like in control panel programs and features?

查看:589
本文介绍了C#:如何让安装程序完全一样的控制面板程序和功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

所以我用:

  1. WMI 的Win32_Product 类。只显示MSI安装程序。
  2. 注册表项。 HKLM \ SOFTWARE \微软\的Windows \ CurrentVersion \卸载。此外,某些程序不能在控制面板中显示,而不是在此注册表节点显示在控制面板中的一些程序。
  1. WMI Win32_Product class. It shows only msi installed programs.
  2. 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:是的,我用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 "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);
                }
            }
        }
    }

推荐答案

好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 = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";

这篇关于C#:如何让安装程序完全一样的控制面板程序和功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆