שתף באמצעות


How to restore the registry value to "value not set"

Question

Thursday, May 10, 2018 12:18 PM

https://superuser.com/questions/1017689/regedit-how-to-reset-to-value-not-set

Please view the page above.

I use the RegistryKey.SetValue("",""), but it set the value to null string, how to restore to "value not set"? 

I cannot delete the key and re-create the key.

All replies (5)

Thursday, May 10, 2018 2:20 PM ✅Answered

In case of default values, try key.DeleteValue("").


Thursday, May 10, 2018 12:34 PM

Did you try passing Nothing instead of an empty string?  The value parameter is an Object type so Nothing should be an acceptable value.

Reed Kimble - "When you do things right, people won't be sure you've done anything at all"


Thursday, May 10, 2018 1:28 PM

Sorry, the error is "value can not be null" to use SetValue("", Nothing).


Thursday, May 10, 2018 2:30 PM

OK, sorry, I see now that a value of null will throw an exception.

You have to use the DeleteValue() method to get "value not set".

Reed Kimble - "When you do things right, people won't be sure you've done anything at all"


Thursday, May 10, 2018 2:31 PM

Sorry for the duplicate, you posted while I was researching the answer. :)

Reed Kimble - "When you do things right, people won't be sure you've done anything at all"