|
-
May 3rd, 2009, 06:10 AM
#1
list all keys, subkeys and values in registry hive
here is a recursive scripting method to get all keys and subkeys in a hive starting from root or any level
takes a while, probably should have a doevents somewhere, to prevent computer lockup while running
vb Code:
Sub getsubkeys(hkey As Long, strpath As String, sk As Variant)
Dim strkeypath As String, subkey As Variant, arrsubkeys As Variant
strkeypath = strpath
If Not Len(sk) = 0 And Not Len(strpath) = 0 Then strkeypath = strpath & "\"
strkeypath = strkeypath & sk
oreg.EnumKey hkey, strkeypath, arrsubkeys
If Not IsNull(arrsubkeys) Then
For Each subkey In arrsubkeys
Debug.Print strkeypath & "\" & subkey ' or print to form or whatever
' for speed considerations should be stored to memory (variable) and written to whatever in sections, trying to read the entire registry into memory may or may not be possible, depending on machine configuration
getsubkeys hkey, strkeypath, subkey
Next
End If
End Sub
' call like
Sub yy()
Const HKEY_CURRENT_USER As Long = &H80000001
strComputer = "."
Set oreg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
getsubkeys HKEY_CURRENT_USER, "", "" ' get from root level
'or
getsubkeys HKEY_CURRENT_USER, "software\adobe", "" ' starting at adobe
Set oreg = Nothing
End Sub
declare oreg as object in the general section
Last edited by westconn1; Dec 24th, 2009 at 07:36 AM.
Reason: modified function arguments
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|