I can get/set registry values using the Microsoft.Win32.Registry class. For example,
Microsoft.Win32.Registry.SetValue(
@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run",
"MyApp",
Application.ExecutablePath);
But I can't delete any value. How do I delete a registry value?
RegistryKey.DeleteValue
To delete the value set in your question:
Look at the docs for
Registry.CurrentUser
,RegistryKey.OpenSubKey
andRegistryKey.DeleteValue
for more info.To delete all subkeys/values in the tree (~recursively), here's an extension method that I use:
Usage: