Search code examples
registrykey-value

Get the Value of a Registry Key in C#


I am trying to get the value of a registry key. I have the following code:

const string keyName = @"HKEY_LOCAL_MACHINE\SOFTWARE\Ansoft\HFSS\2014.0\Desktop";
string value = (string)Registry.GetValue(keyName, "LibraryDirectory", null);

I keep getting null for value. Here is a screenshot of the registry key in regedit:

Regedit


Solution

  • See answer here: Registry.GetValue always return null