I simply want to loop through a registry key, and have all subkeys and
values outputed to the console window. It needs to be recursive, so it keeps
going into each key one at a time, until it finishes. My code is not close.
Anybody have code that has done this?
Dim GroupID As Long = 39
'Dim RegKey As RegistryKey =
Registry.LocalMachine.OpenSubKey("SYSTEM\CurrentCo ntrolSet\Services\LanmanS*erver\Shares")
Dim RegKey As RegistryKey =
Registry.CurrentUser.OpenSubKey("Software").OpenSu bKey("VB and VBA Program
Settings").OpenSubKey("iGen").OpenSubKey("Group"). OpenSubKey(GroupID).OpenSubKey("Printer
Settings")
Dim tempKey As RegistryKey
Do Until RegKey.SubKeyCount = 0
Console.WriteLine("There are {0} subkeys under " & RegKey.Name & ".",
RegKey.SubKeyCount.ToString())
Console.WriteLine(vbCrLf & "There are {0} values for " & "{1}.",
RegKey.ValueCount.ToString(), RegKey.Name)
For Each valueName As String In RegKey.GetValueNames()
Console.WriteLine("{0,-8}: {1}", valueName,
RegKey.GetValue(valueName.ToString))
Next
For Each subKeyName As String In RegKey.GetSubKeyNames()
tempKey = RegKey.OpenSubKey(subKeyName)
Console.WriteLine(vbCrLf & "There are {0} values for " & "{1}.",
tempKey.ValueCount.ToString(), tempKey.Name)
For Each valueName As String In tempKey.GetValueNames()
Console.WriteLine("{0,-8}: {1}", valueName,
tempKey.GetValue(valueName.ToString))
Next
Next
If Not tempKey Is Nothing Then RegKey = tempKey
Loop
Console.ReadLine()
End Sub