Public Function GetAllChildSubKeys(ByVal MainKey As RegistryKey, ByVal sKey As String) As ArrayList Dim rkKey As RegistryKey 'RegistryKey to work with Dim sSubKeys() As String 'string array to hold the subkeys Dim arySubKeys As New ArrayList 'arraylist to return the subkeys in an array Try 'open the given subkey rkKey = MainKey.OpenSubKey(sKey) 'check to see if the subkey exists If Not sKey Is Nothing Then 'subkey exists 'get all the child subkeys sSubKeys = rkKey.GetSubKeyNames 'loop through all the child subkeys For Each s As String In sSubKeys 'add them to the arraylist arySubKeys.Add(s) Next Else 'subkey doesnt exist 'throw an exception Throw New Exception("The SubKey provided doesn't exist. Please check your entry and try again.") End If Catch ex As Exception MessageBox.Show(ex.Message, "Error: Retrieving SubKeys", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try 'return the subkeys arraylist Return arySubKeys End Function
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)