C#获取Office ClickToRun注册表项返回null [英] C# get Office ClickToRun Registry Key returns null

查看:187
本文介绍了C#获取Office ClickToRun注册表项返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望从注册表项"HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Office \ ClickToRun \ Configuration"中获取一些信息.

I whant to get some Information from the Registry Key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\ClickToRun\Configuration".

在某些情况下,我没有获得注册表项对象.为了进行故障排除,我尝试了以下方法:

For some case I do not get the registry key object. For troubleshooting I've tryed the following:

RegistryKey k2 = Registry.LocalMachine.OpenSubKey("SOFTWARE");
RegistryKey k3 = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft");
RegistryKey k4 = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Office");
RegistryKey k5 = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Office\\ClickToRun");

调试代码,这就是我所拥有的:

Debuging the code this is what I've got:

k2->正确的对象

k3->正确的对象

k4->正确的对象

k5->空

我已经多次检查了密钥的名称,当然该密钥存在于系统中.

I have checked the name of the key several times and of course the key exists on the system.

当我像这样搜索SubKey k4时:

When I search SubKey k4 like that:

foreach (string test in k4.GetSubKeyNames()) {
    test.ToString();
}

我找不到键"ClickToRun",但可以找到一些未与regedit一起显示的键.用其他注册表项测试了代码,效果很好.

I can't find the key "ClickToRun" but I can find some keys that aren't shown with regedit. Tested the code with other registrykeys, it works fine.

有什么想法吗?

推荐答案

问题出在64位注册表上.我已经在64位mashine上安装了32位Office.现在,我使用64位注册表项,它可以正常工作.

The problem was about the 64 bit registry. I have installed a 32 bit Office on a 64 bit mashine. Now I use the 64 bit registry entrys and it works fine.

有关更多信息,请参见此文章:

See this artice for more information:

从32位应用程序中读取64位注册表

这篇关于C#获取Office ClickToRun注册表项返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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