Results 1 to 4 of 4

Thread: Getting all sub keys from a registry value

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2006
    Posts
    67

    Getting all sub keys from a registry value

    Hi there,

    Trying to do something I hope would be very simple (but maybe not!)

    I am reading a registry key using the following code:

    Code:
     Dim registry As Object
    
    
        Set registry = CreateObject("WScript.Shell")
    
    
        Registry_Read = registry.RegRead(Key_Path & Key_Name)
       
       
    End Function
    
    
    
    Private Sub cmdgetemails_Click()
       
    
    MsgBox Registry_Read("HKEY_CURRENT_USER\software\microsoft\windows\currentversion\unreadmail", "")
    
    End Sub
    What I want to do now is read all the sub keys in that particular key.. but im finding it extremely hard, is there is a simple way of doing this?

    Many thanks

  2. #2
    Fanatic Member schoolbusdriver's Avatar
    Join Date
    Jan 2006
    Location
    O'er yonder
    Posts
    1,020

    Re: Getting all sub keys from a registry value

    Quote Originally Posted by Stanuk
    is there is a simple way of doing this?
    Debateable

    WSH doesn't support registry enumeration. You can use WMI (.EnumKey), RegEnumKeyEx, SHEnumKeyEx, SHRegEnumUSKey or ZwEnumerateKey.

    WMI is easiest. The rest are more reliable as they cannot be disabled by the user.

  3. #3
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: Getting all sub keys from a registry value

    Since the sample was missing:
    Code:
    Option Explicit
    
    Private Sub Form_Load()
        Dim Registry As Object, varKey As Variant, varKeys As Variant
        Set Registry = GetObject("winmgmts:\\.\root\default:StdRegProv")
        Registry.EnumKey &H80000001, "software\microsoft\windows\currentversion\unreadmail", varKeys
        For Each varKey In varKeys
            Debug.Print varKey
        Next
    End Sub
    MSDN: EnumKey method of the StdRegProc class

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Sep 2006
    Posts
    67

    Re: Getting all sub keys from a registry value

    That worked a treat, thankyou very much :-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width