take this code to get,update,delete registery values
Gets a value data for a specific ValueName in the registry
Public Function GetFromRegistry(ByVal KeyPath As String, ByVal ValueName As String) As String
Dim regKey As RegistryKey
Dim strValueData As String
Try
Open the key with write access
regKey = Registry.LocalMachine.OpenSubKey(KeyPath, False)
If regKey Is Nothing Then
Exit Function
End If
Get the data of [ValueName] Value, if no data is found return ""
strValueData = CStr(regKey.GetValue(ValueName, ""))
Return strValueData
Catch ex As Exception
Return ""
End Try
End Function
Saves a value name with its data and parent key in the registry
Public Sub SaveToRegistry(ByVal KeyPath As String, ByVal ValueName As String, ByVal ValueData As Object)
Dim regKey As RegistryKey
Try
Open the key with write access
regKey = Registry.LocalMachine.OpenSubKey(KeyPath, True)
If not found, create the key
If regKey Is Nothing Then
Create a key in HKEY_LOCAL_MACHINE\[Path] with a name of [ValueName]
regKey = Registry.LocalMachine.CreateSubKey(KeyPath)
End If
Set a new value
regKey.SetValue(ValueName, ValueData)
Catch ex As Exception
Throw New System.Exception("Error saving to registry")
End Try
End Sub
Delete a value for a parent key in the registry
Public Sub DeleteFromRegistry(ByVal KeyPath As String, ByVal ValueName As String)
Dim regKey As RegistryKey
Try
Open the key with write access
regKey = Registry.LocalMachine.OpenSubKey(KeyPath, True)
regKey.DeleteValue(ValueName)
Catch ex As Exception
End Try
End Sub