Represents a key level node inside the Windows Registry.


This class allows for easy access and manipulation of keys and key values within the Windows Registry. By using a key naming convention similar to folders the keys and values can be traversed and modified.

There a set of Root nodes that separate the Registry to common areas for specific needs. The Root nodes are the starting place for any keys in the registry. A key name could look like HKEY_LOCAL_MACHINE\Software'.

 Iterate the values found in a registry key.

 Private Sub Main()
     Dim rk As RegistryKey
     Dim names() As String
     Dim i As Long

     ' Open a registry subkey for enumeration.
     Set rk = Registry.LocalMachine.OpenSubKey("software\microsoft\windows\currentversion\run")

     ' Retrieve all names for the values in the key.
     names = rk.GetValueNames

     ' enumerate the names and get the value for each,
     ' displaying the pair as [name] = [value].
     For i = 0 To UBound(names)
         Console.WriteLine "{0} = {1}", names(i), rk.GetValue(names(i))
     Next i

     ' Close the registry key.

     ' Wait for user to hit return.
 End Sub

 'This code produces the following output.
 'The list will vary from machine to machine.

 'CplBCL50 = C:\Program Files\EzButton\CplBCL50.EXE
 'ccApp = "C:\Program Files\Common Files\Symantec Shared\ccApp.exe"
 'Symantec NetDriver Monitor = C:\PROGRA~1\SYMNET~1\SNDMon.exe

See Also

Project VBCorLib Overview | Registry | RegistryKeyStatic





 RegistryValueKindThe value types that can be set and retrieved from the Registry. 


 Name (get)Returns the name of the key. 
 SubKeyCount (get)Returns the number of SubKeys within the current key. 
 ValueCount (get)Returns the number of values within the current key. 


 CloseKeyCloses the RegistryKey object. 
 CreateSubKeyCreates a new Windows Registry node. 
 DeleteSubKeyDeletes a node from the Windows Registry. 
 DeleteSubKeyTreeDeletes all SubKeys within the specified SubKey to delete. 
 DeleteValueDeletes the value from the registry. 
 EqualsReturns a boolean indicating if the value and this object instance are the same instance. 
 FlushFlushes any changes to the Windows Registry back to disk. 
 GetEnumeratorReturns an enumerator to enumerate the name/value pairs. 
 GetHashCodeReturns a pseudo-unique number identifying this instance. 
 GetLastWriteTimeReturns the last time the subkey was written to. 
 GetSubKeyNamesReturns a list of SubKey names within the current SubKey. 
 GetValueReturns the value of a key within a SubKey. 
 GetValueKindReturns the type of value stored in the registry. 
 GetValueNamesReturns a list of value names within the current SubKey. 
 OpenSubKeyReturns a RegistryKey of the requested SubKey with the write permission specified. 
 SetValueSets the value of a key value within the SubKey. 
 ToStringReturns a string representation of this object instance.