You're using the wrong overload of
Registry.OpenSubkey[
^].
Registry.OpenSubkey(String)
opens as read-only. Use
RegistryKey.OpenSubKey(String, Boolean)
instead. ie:
Public Sub SavePreference(ByVal pref As String, ByVal value As String)
Dim tmp As RegistryKey = Registry.CurrentUser
Dim tmp2 As RegistryKey
tmp2 = tmp.OpenSubKey("SOFTWARE\example", True)
If tmp2 Is Nothing Then
tmp.CreateSubKey("SOFTWARE\example")
tmp2 = tmp.OpenSubKey("SOFTWARE\example", True)
End If
If tmp2 IsNot Nothing Then tmp2.SetValue(pref, LCase(value))
End Sub