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 :)
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.
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
Re: Getting all sub keys from a registry value
That worked a treat, thankyou very much :-)