Also
Function RegistryRetrieve(parent As RegistryKey, keyName As String,
valueName As String) As String
' Recursively search through each subkey of a parent key
' checking to see if a match for the keyname exist and
if
' the data can be obtained from that key. Returns data
upon
' match and an error message otherwise.
Dim childName As String
For Each childName In parent.GetSubKeyNames()
Try
Dim child As RegistryKey =
parent.OpenSubKey(childName)
Dim data As String = Nothing
If child.Name.EndsWith(keyName) Then
' We found the name, try to pull out
key data
data = child.GetValue(valueName)
Else
' No luck finding the name, try a
depth-first recursive search
data = RegistryRetrieve(child, keyName,
valueName)
End If
If Not (data Is Nothing) Then
Return data
End If
Catch ex As Exception
' Print out a message whenever we come
across a
' key we don't have permissions to open
Console.WriteLine((childName + ": " +
ex.Message))
End Try
Next childName
Return Nothing
End Function