无法访问 Windows Server 2008 Enterprise 上的 HKEY_CLASSES_ROOT\Installer [英] Cannot access HKEY_CLASSES_ROOT\Installer on Windows Server 2008 Enterprise

查看:71
本文介绍了无法访问 Windows Server 2008 Enterprise 上的 HKEY_CLASSES_ROOT\Installer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果有人能帮助我解决我所遇到的问题,我将不胜感激.

I'd appreciate if someone can help me out with the issue I am stack on.

我用C#写了一个简单的程序来检查下面的key是否存在HKEY_CLASSES_ROOT\Installer\UpgradeCodes\product_upgrade_GUID

I wrote a simple program in C# to check if the following key exists HKEY_CLASSES_ROOT\Installer\UpgradeCodes\product_upgrade_GUID

除了在 Windows Server Enterprise 2008 x64 SP2 上它返回 System.NullReferenceException 之外,它在所有 Windows 上(如果密钥存在)返回 true,尽管密钥存在.实际上,如果我尝试访问 \Installer 注册表中的任何键,我会得到 NullReferenceException.看起来这个安装程序密钥以某种方式受到保护.尝试访问HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UpgradeCodes"键时会发生同样的事情.

It returns true on all Windows (if the key exists) except on Windows Server Enterprise 2008 x64 SP2 where it returns System.NullReferenceException although the key exists. Actually I get NullReferenceException if I try to access any key inside the \Installer registry. It looks like this Installer key is somehow protected. Same thing happens when trying to access "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UpgradeCodes" key.

以下代码应返回HKEY_CLASSES_ROOT\Installer",但返回 NullReferenceException:

The following code should return "HKEY_CLASSES_ROOT\Installer" but it returns NullReferenceException:

RegistryKey rk = Registry.ClassesRoot.OpenSubKey(@"Installer");
return rk.ToString();

有人知道访问安装程序 Windows 注册表的任何限制吗?(UAC 已禁用,用户为管理员)

Does anyone know any limitations for accessing the Installer Windows registry? (UAC is disabled and user is admin)

谢谢

推荐答案

您很可能在 64 位系统上运行 32 位进程,并且 注册表重定向器 将带您进入注册表的 32 位视图.那些键不存在的地方.

Most likely you are running a 32 bit process on a 64 bit system and the registry redirector is taking you to the 32 bit view of the registry. Where those keys do not exist.

您的选择包括:

  • 使用 RegistryView 枚举.请注意,这需要 .net 4.对于旧版本的 .net,您需要使用 p/invoke 从 32 位进程读取注册表的 64 位视图.
  • 切换到 64 位进程.

这篇关于无法访问 Windows Server 2008 Enterprise 上的 HKEY_CLASSES_ROOT\Installer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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