1

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?

Wolfy
  • 11
  • 1
  • According to the article about the change, "Existing code running inside the Visual Studio process is not impacted. Visual Studio will redirect all registry operations under the HKCU Visual Studio-specific key to the private registry." so there is no HKLM equivalent. – NetMage Apr 20 '18 at 17:44

1 Answers1

0

Thank you NetMage for pointing me into the right direction. I was able to change the registry entries i needed using Microsoft.Win32.Registry.CurrentUser.OpensSubKey("@Software\Microsoft\VisualStudio\15.0_Config", true);

It seems actually to be no more need of a LOCAL_MACHINE registry in Visual Studio 2017, so no admin privileges are required to setup Visual Studio components.

Wolfy
  • 11
  • 1