GetSubKeyNames 不返回所有键 [英] GetSubKeyNames does not return all keys

查看:52
本文介绍了GetSubKeyNames 不返回所有键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在客户端上安装软件.我也使用 WMI 和注册表.

I want to get the software installed on the client. I use WMI and the registry as well.

我在HKLM\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\UNINSTALL下找到了大部分信息

I find most of the information under HKLM\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\UNINSTALL

但是,例如 Dropbox,没有出现在那里.Dropbox 位于 HKCU 下,所以我也想阅读这些密钥.很简单,我想,因为路径是一样的,只是 RegistryHive 发生了变化.

However, Dropbox for example, does not appear there. Dropbox is located under HKCU so I want to read those keys as well. Simple, I thought, cause the path is the same, just the RegistryHive changes.

问题

当我在 CurrentVersion 中使用函数 GetSubKeyNames 时,我看不到 UNINSTALL 键.

I can not see the key UNINSTALL though when I'm in CurrentVersion using the function GetSubKeyNames.

var root = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry32)

var key = root.OpenSubKey(@"SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION") // works
var key = root.OpenSubKey(@"SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\Uninstall") // doesnt work

我也用 RegistryView.Registry64 尝试了这个 - 我得到了相同的结果.

Also I tried this with RegistryView.Registry64 - I get the same result.

当我使用 GetSubKeyNames 时打印的内容如下:

Whats printed out when I use GetSubKeyNames is the following:

Device Metadata
Explorer
Group Policy
GrpConv
Internet Settings
Media Center
Run
Shell Extensions
Telephony
ThemeManager
WinTrust

有人知道我该如何解决这个问题吗?

Does anybody know how I can fix this issue?

推荐答案

我也遇到了这个问题,检查了 32 位和 64 位视图都有效.

I ran into this issue as well, checking both the 32-bit and 64-bit views worked.

        var HKLM32 = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, "computername", RegistryView.Registry32);
        var HKLM64 = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, "computername", RegistryView.Registry64);
        key32 = HKLM32.OpenSubKey(registryKeytoFind);
        key64 = HKLM64.OpenSubKey(registryKeytoFind);

这篇关于GetSubKeyNames 不返回所有键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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