James346
James346

Reputation: 197

Deleting a single registry value in C#

Is there any way to delete a single registry entry in C#? All the deletion methods will remove the whole subkey rather than a single value.

Registry.SetValue(@"My\Reg\Key\Path", "MyValue", null);

The above example isn't valid to Microsoft.Win32, but hopefully you see what i'm getting at.

Upvotes: 0

Views: 36

Answers (1)

Mathias R. Jessen
Mathias R. Jessen

Reputation: 174920

Open the appropriate key in read/write mode and invoke the DeleteValue() method:

var regKey = Registry.LocalMachine.OpenSubKey(@"path\to\subkey",true);
regKey.DeleteValue("MyValue");

Upvotes: 3

Related Questions