|
Dim Sb as new system. Text. stringbuilder 'returns the traversal result
Dim sb2 as new system. Text. stringbuilder 'returns the registry key with an error in reading.
Private sub button3_click () sub button3_click (byval sender as system. object,
Byval e as system. eventargs) handles button3.click
Dim key1 as Microsoft. win32.registrykey
Key1 = My. Computer. Registry. currentuser 'return the current user key
If not key1 is nothing then
SB. appendline (key1.name)
Readvalue (key1)
Readreg (key1)
End if
Me. textbox1.text = sb. tostring
Me. textbox2.text = sb2.tostring
End sub
'Traverse the registry key tree
Private sub readreg () sub readreg (byval R as Microsoft. win32.registrykey)
If R. subkeycount> 0 then
Dim keyname () as string
Dim keytemp as Microsoft. win32.registrykey
Keyname = R. getsubkeynames
Dim I as integer
For I = 0 to keyname. getlength (0)-1
Try
SB. appendline (keyname (I ))
Keytemp = R. opensubkey (keyname (I), true)
Readvalue (keytemp)
Readreg (keytemp)
Catch ex as exception
Sb2.appendline (keyname (I ))
End try
Next
End if
End sub
'Traverse the items under a key
Private sub readvalue () sub readvalue (byval R as Microsoft. win32.registrykey)
If R. valuecount> 0 then
Dim valuename () as string
Dim I as integer
Valuename = R. getvaluenames
For I = 0 to valuename. getlength (0)-1
SB. appendline ("####")
SB. append (R. Name)
SB. append ("----")
SB. append (R. getvalue (valuename (I). tostring)
Next
End if
End sub |