Click here to Skip to main content
12,999,010 members (48,397 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hello I am aware that the registry class exists for but am a bit confused as to how its possible to enumerate all levels to a label or textbox in succession one key after another like a virus scanner iterating over a filesystem.

I have been trying to use this bit of code that I have found can anyone shed a bit of knowledge on this?

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
           '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
           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

Thank you in advance!!
Posted 24-Oct-12 17:34pm
Dale 20121.8K
Sergey Alexandrovich Kryukov 24-Oct-12 23:44pm
And what's the question? What's is the problem?
Dale 2012 24-Oct-12 23:54pm
the question to my problem is simply to show the recursion of the registry to a label like a scanner normally would. I would like to enumerate all levels of the registry and have a label show it. how might I accomplish this?
What's the problem with your current code?

Also, there is no need to use Win32 API (I refer to your next question I removed as re-post). Why did you ask? you already started to use Microsoft.Win32.Registry from FCL...
Dale 2012 26-Oct-12 21:57pm
I am only looking for some example with some insight into things as i am trying to learn but it is confusing to me and this code is also a bit confusing. what is FCL?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170622.1 | Last Updated 24 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100