I have made a number of functions that increase the transformation of the registry key, you can copy it when you need:
Imports microsoft.win32 'provided by mscorlib.dll
Public Class RegistryAccess
Public Shared Function GetRegistryKey (ByVal registryRoot As RegistryKey, ByVal keyName As String, ByVal valueName As String) As Object '' registryKey = Microsoft.Win32.Registry.LocalMachine | .ClassesRoot | .CurrentConfig | .CurrentUser | .DynData | .PerformanceData |. Users' keyName = "Software // Microsoft // IE Setup / Setup" 'valueName = "Path"' Dim subKey As RegistryKey subKey = registryRoot.OpenSubKey (keyName, False) Dim valueData As Object If (Not subKey Is Nothing) Then valueData = Subkey.getValue (Valuename) Subkey.close () end if return valuedata
END FUNCTION
Public Shared Function SetRegistryKey (ByVal registryRoot As RegistryKey, ByVal keyName As String, ByVal valueName As String, ByVal valueData As Object) As Boolean 'Dim subKey As RegistryKey subKey = registryRoot.OpenSubKey (keyName, True) If subKey Is Nothing Then' Create it If it doesn't exist subkey = registryroot.createSubkey (keyname) endiff
IF (NOT Subkey Is Nothing) THEN Subkey.SetValue (Valuename, Valuedata) Subkey.close () Else 'Failure Return False End If Return True End Function
Public Shared Function DeleteRegistryKey (ByVal registryRoot As RegistryKey, ByVal keyName As String, Optional ByVal ErrorOnFail As Boolean = False) As Boolean 'Try registryRoot.DeleteSubKeyTree (keyName) Return True Catch ex As Exception If ErrorOnFail Then Throw ex Else Return False End If End Trynd Function
End class ------------------ Call Method Example: RegistryAccess.setRegistryKey (Microsoft.Win32.Registry.Localmachine, "Software // Company name // section name // key name "," Valuename "," Valuedata ")