1

I want to get the registry value with the following piece of code

object key_10 = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\14.0\Common\InstallRoot", "Path", null);

Generally it works but when I run it on Windows Server 2012 R2 Terminal I get a null value. I have local administrator rights. The value exists in the registry (checked with regedit.exe) .NET Framework is 4.5

Sebastian Widz
  • 1,962
  • 4
  • 26
  • 45
  • You can't see that key when your program is forced to run in 32-bit mode. Google "registry redirector" to learn more. Remove the jitter forcing or use RegistryKey.OpenBaseKey() so you can specify the view. – Hans Passant Jun 08 '16 at 12:18

1 Answers1

0

If it returns null, set your build architecture to Any CPU. The operating system may virtualize 32-bit and 64-bit registries differently.
Reference:
reading-64bit-registry-from-a-32bit-application

Community
  • 1
  • 1
Ajit Medhekar
  • 1,018
  • 1
  • 10
  • 39