NewsInternationalLtd
asked on
How do I delete a VALUE NAME from the registry?
I need to be able to delete a value name from the registry in VB.NET but there appears to be no provision for this, with only DELETEVALUE, DELETESUBKEY or DELETESUBKEYTREE available.
The attached code cycles through a regisrty subkey looking at the value names and uses DELETEVALUE to try and delete one of the value names if it finds a match to a label I have on the form. Unfortunately this just results in an exception saying the value doesn't exist. Can anyone suggest a way around this for me?
Thank you
Simon
The attached code cycles through a regisrty subkey looking at the value names and uses DELETEVALUE to try and delete one of the value names if it finds a match to a label I have on the form. Unfortunately this just results in an exception saying the value doesn't exist. Can anyone suggest a way around this for me?
Thank you
Simon
Dim R2 As Microsoft.Win32.RegistryKey = Registry.CurrentUser.OpenSubKey("Software\test\ProxyAdmin")
Dim a2() As String = R2.GetValueNames
For i = 0 To a2.GetUpperBound(0)
If R2.GetValueNames(i) = lblProxy1.Text Then My.Computer.Registry.CurrentUser.DeleteValue("Software\test\ProxyAdmin\" & lblProxy1.Text)
Next
For i = 0 To a2.GetUpperBound(0)
ComboBox1.Items.Add(R2.GetValueNames(i))
Next
My.Computer.Registry.Curre ntUser().D eleteSubKe y("Softwar e\_DeleteM e")
What is the text in lblProxy1.Text?
ASKER
lblProxy1.Text is the valuename itself whivh I would like to delete.
Wouldn't the code above just delete the key?
Wouldn't the code above just delete the key?
Here you go. This worked perfect for me:
Dim key As Microsoft.Win32.RegistryKe y = _
My.Computer.Registry.Curre ntUser.Ope nSubKey("S oftware\_D eleteMe2", True)
key.DeleteValue("DeleteThi sValue")
key.Close()
Dim key As Microsoft.Win32.RegistryKe
My.Computer.Registry.Curre
key.DeleteValue("DeleteThi
key.Close()
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thanks, worked a treat.