最佳答案
我正在尝试获取这个键中所有子键的显示名称:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
用这个密码:
RegistryKey newKey;
string val;
string KeyPath64Bit = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
RegistryKey mainKey = Registry.LocalMachine.OpenSubKey(KeyPath64Bit);
string[] RegKeys64Bits = Registry.LocalMachine.OpenSubKey(KeyPath64Bit).GetSubKeyNames();
foreach (string s in RegKeys64Bits)
{
newKey = mainKey.OpenSubKey(s);
val = newKey.GetValue("DisplayName", -1, RegistryValueOptions.None).ToString();
if (val != "-1")
file64.WriteLine(val);
}
在运行了代码之后,我找不到我需要的一个键:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{DA5E371C-6333-3D8A-93A4-6FD5B20BCC6E}
它应该有一个显示名称: Microsoft Visual C + + 2010 x64 Redistribution-10.0.30319,但是 GetSubKeyNames()方法给了我一个子键: {DA5E371C-6333-3D8A-93A4-6FD5B20BCC6E}.KB2151757,它没有任何显示名称。
为什么我不能得到确切的子密钥我需要({DA5E371C-6333-3D8A-93A4-6FD5B20BCC6E}) ,我怎样才能得到它?