如何读取注册表项Software\Microsoft \ Windows \ CurrentVersion \ Uninstall [英] How read registry key Software\Microsoft\Windows\CurrentVersion\Uninstall

查看:230
本文介绍了如何读取注册表项Software\Microsoft \ Windows \ CurrentVersion \ Uninstall的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个代码。但它不会返回结果。我犯了什么错误?



I have this code. But it not return result. what i make wrong?

RegistryKey branch = Registry.CurrentUser;
            branch = branch.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall", Microsoft.Win32.RegistryKeyPermissionCheck.ReadSubTree, System.Security.AccessControl.RegistryRights.ReadKey);
            string[] keys = branch.GetValueNames();

推荐答案

似乎 GetValueNames 返回空集合。如下所示,您将获得子键名称和显示名称。

it seems GetValueNames return empty collection. check like below, you will get the sub key names and display names.
RegistryKey branch = Registry.CurrentUser;
branch = branch.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall", Microsoft.Win32.RegistryKeyPermissionCheck.ReadSubTree, System.Security.AccessControl.RegistryRights.ReadKey);
var subKeyNames =branch.GetSubKeyNames();
var DisplayNames = new List<string>();
foreach (string subkey_name in branch.GetSubKeyNames())
{
    using (RegistryKey subkey = branch.OpenSubKey(subkey_name))
    {
        DisplayNames.Add((string)subkey.GetValue("DisplayName"));
    }
}





并检查以下答案

C#:如何安装程序与控制面板程序和功能完全相同? [ ^ ]


这篇关于如何读取注册表项Software\Microsoft \ Windows \ CurrentVersion \ Uninstall的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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