-1

I'm getting: Access Denied HKEY_LOCAL_MACHINE

What is the wrong with this code?

var key = "SOFTWARE\\Microsoft\\Expression\\Encoder\\4.0";

using (var registryKey = Registry.LocalMachine.OpenSubKey(key))
{
    if (registryKey == null)
    {
        using (var newKey = Registry.LocalMachine.CreateSubKey(key))
        {
            CheckInstallKey(newKey);
        }
    }
    else
    {
        CheckInstallKey(registryKey);
    }
}

Error:

enter image description here

elmigue017
  • 343
  • 2
  • 12
Ahmed Alayat
  • 111
  • 2
  • 11

1 Answers1

1

run your code as administrator

HKLM is just for local system and administrators

HKCU is for regular users