Skip to content

Instantly share code, notes, and snippets.

@bpatra
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bpatra/bd641ee939f2c70ed3d9 to your computer and use it in GitHub Desktop.
Save bpatra/bd641ee939f2c70ed3d9 to your computer and use it in GitHub Desktop.
Choosing the proper registry
RegistryKey baseRegistryHklm;
RegistryKey baseRegistryHkcu;
if (Environment.Is64BitOperatingSystem) //Use OS not process...
{
baseRegistryHklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
baseRegistryHkcu = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry64);
}
else
{
baseRegistryHklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
baseRegistryHkcu = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry32);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment