C# get Office ClickToRun Registry Key returns null

China☆狼群 提交于 2020-01-07 09:21:00

问题


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 -> correct Object

k3 -> correct Object

k4 -> correct Object

k5 -> null

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

When I search SubKey k4 like that:

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

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.

Any ideas?


回答1:


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:

Reading 64bit Registry from a 32bit application



来源:https://stackoverflow.com/questions/34062835/c-sharp-get-office-clicktorun-registry-key-returns-null

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!