Click here to Skip to main content
15,907,874 members

Comments by aljeff (Top 3 by date)

aljeff 24-Jan-13 12:06pm View    
I tried for HKLM first. It worked but I didn't load all the subkey of HKLM.

Here's what I did as per your instructions.


Private Function CreateNodes(ByVal vParentNode As TreeNode, ByVal vRegKey As RegistryKey) As TreeNode

Try

For Each vSubKeyName As String In vRegKey.GetSubKeyNames()
Dim vSubKey As RegistryKey = vRegKey.OpenSubKey(vSubKeyName, RegistryKeyPermissionCheck.Default, Security.AccessControl.RegistryRights.ReadKey)
Dim vChildNode As New TreeNode(vSubKeyName)
vChildNode = CreateNodes(vChildNode, vSubKey)
vParentNode.Nodes.Add(vChildNode)
Next

Catch ex As SecurityException
Catch ex As Exception

End Try

Return vParentNode

End Function
aljeff 24-Jan-13 11:53am View    
If I remove the try catch outside the loop it will return an error because of security issues.

Im getting confused.
aljeff 24-Jan-13 11:49am View    
Deleted
Sorry, but I didn't get the instruction.

Like this?

<pre lang="vb">
Private Function CreateNodes(ByVal vParentNode As TreeNode, ByVal vRegKey As RegistryKey) As TreeNode

For Each vSubKeyName As String In vRegKey.GetSubKeyNames()

Try
Dim vSubKey As RegistryKey = vRegKey.OpenSubKey(vSubKeyName, RegistryKeyPermissionCheck.Default, Security.AccessControl.RegistryRights.ReadKey)
Dim vChildNode As New TreeNode(vSubKeyName)
vChildNode = CreateNodes(vChildNode, vSubKey)
vParentNode.Nodes.Add(vChildNode)

End Try
Next
Catch ex As SecurityException
Catch ex As Exception
Return vParentNode

End Function
</pre>