Search code examples
c#c#-4.0registry

What is the difference between Registry.LocalMachine and RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Default)


What is the difference between Registry.LocalMachine and RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Default)?

And if there is no difference at all, what would be the preferred solution to use? For backwards compatibility with older .NET frameworks only the first solution (Registry.LocalMachine) is available but which API will survive in the future?

Registry.LocalMachine solution on MSDN: http://msdn.microsoft.com/en-us/library/microsoft.win32.registry.localmachine.aspx

RegistryKey.OpenBaseKey solution on MSDN: http://msdn.microsoft.com/en-us/library/microsoft.win32.registrykey.openbasekey.aspx


Solution

  • If you just want the default view (Registry64 for a 64-bit app, Registry32 for a 32-bit app), then I'd use the first.