Highwayman

How do you access the registry and list all sub keys for a specified key.

In this example I would like to retrieve all the sub keys for JavaSoft:

Registry keys

HKEY_CURRENT_USER\Software\JavaSoft

HKEY_CURRENT_USER\Software\JavaSoft\Java Runtime Environment

HKEY_CURRENT_USER\Software\JavaSoft\Java Update

HKEY_CURRENT_USER\Software\JavaSoft\Java2D

This is what I would want to put in a listbox:

Java Runtime Environment

Java Update

Java2D

How would I loop through the relevant sub keys using OpenSubKey, I have tried a number of ways but either get errors or nothing.



Re: Visual Basic Express Edition Listing registry sub keys

Rykler

Try this

Code Block

For Each Key As String In My.Computer.Registry.CurrentUser.OpenSubKey("Software\JavaSoft").GetSubKeyNames

ListBox1.Items.Add(Key)

Next

You can also cut that down to one line with this

Code Block

ListBox1.Items.AddRange(My.Computer.Registry.CurrentUser.OpenSubKey("Software\JavaSoft").GetSubKeyNames)





Re: Visual Basic Express Edition Listing registry sub keys

Highwayman

Thank you very much.