I need to access the private registry from Visual Studio 2017 from a c# program, so the changes there can be used from the running VS instance. To do so I have written an extension that starts a C# method at the startup of Visual Studio. There is a very good idea how to access the private registry here: Access Visual Studio 2017's private registry hive Unfortunately the method described there using CreateForApplication works only on CurrentUser. I've tried to replace Registry.CurrentUser.OpenSubKey with Registry.LocalMachine.OpenSubKey but I'm getting the keys from the normal Windows registry there:
String exeName = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
ExternalSettingsManager ext = ExternalSettingsManager.CreateForApplication(exeName);
WritableSettingsStore store = ext.GetWritableSettingsStore(SettingsScope.UserSettings);
RegistryKey privateRegKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\VisualStudio\", true);
String[] subkeys = privateRegKey.GetSubKeyNames();
privateRegKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\VisualStudio\", true);
subkeys = privateRegKey.GetSubKeyNames();
I'v also started Visual Studio as administrator. Can anyone help me and tell me how to modify the private registry for the LocalMachine hive using RegistryKey calls?