Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
Hello I am aware that the registry class exists for vb.net 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
       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
 

Thank you in advance!!
Posted 24-Oct-12 18:34pm
Dale 20121.8K
Comments
Sergey Alexandrovich Kryukov at 24-Oct-12 23:44pm
   
And what's the question? What's is the problem?
--SA
Dale 2012 at 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?
Sergey Alexandrovich Kryukov at 26-Oct-12 0:32am
   
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...
--SA
Dale 2012 at 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
0 BillWoodruff 260
1 Mathew Soji 244
2 Afzaal Ahmad Zeeshan 232
3 OriginalGriff 231
4 Maciej Los 230
0 OriginalGriff 6,369
1 Sergey Alexandrovich Kryukov 5,973
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 4,045


Advertise | Privacy | Mobile
Web02 | 2.8.1411019.1 | Last Updated 24 Oct 2012
Copyright © CodeProject, 1999-2014
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