If you need to get the registry keys recursively you can use this function. This fills the textbox with the registry key and all inside.
The usual imports:
The code is generated by a call:
Dim key As String = txtKey.Text
TextBox1.Text = ""
TextBox1.Text = GetMyStrings(key)
This works for the HKEY_LOCAL_MACHINE main key. You can easily change to get the others.
First you open the main key with this:
Dim i As Integer
Dim k As String = key & vbCrLf
Dim k1 As String = ""
Dim R As Microsoft.Win32.RegistryKey = Registry.LocalMachine.OpenSubKey(key)
Dim a() As String = R.GetSubKeyNames
The R var opens the key and now we can get those subkeynames to an array. And now it is time to read all values inside this key with:
k += GetMyKeys(key)
This function reads those values and returns a string with it.
The secret for this to recursively works is in the GetMyStrings function. Let's see it:
For i = 0 To a.Length - 1
k1 = key & "\" & a(i)
k += k1 & vbCrLf
If Registry.LocalMachine.OpenSubKey(k1).SubKeyCount > 0 Then
k += GetMyStrings(k1)
Let's go key by key and check if there are another keys inside this one and if there are, just call this function recursively. The new parameter is the new key. And the function just goes and do the work.