C#C
C#2y ago
Remaetanju

Trouble reading registry

  string value64 = string.Empty;
  string value32 = string.Empty;

  const string subkey = @"Test";
  const string valueName = "Testvalue";

  RegistryKey localKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
  localKey = localKey.OpenSubKey(subkey);
  if (localKey != null)
  {
      value64 = localKey.GetValue(valueName).ToString();
      MessageBox.Show(value64);

  }
  RegistryKey localKey32 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
  localKey32 = localKey32.OpenSubKey(subkey);
  if (localKey32 != null)
  {
      value32 = localKey32.GetValue(valueName).ToString();
      MessageBox.Show(value32);

  }

I'm in a lot of trouble to read a single value from the registry
i've tried various codes snippets but everytime my code just doesnt find the key
Was this page helpful?