. NET Scan remote computer registry
Last Update:2017-02-28
Source: Internet
Author: User
Registry ' sometimes needs to scan the registry of a remote computer, determine whether some key value items exist or not, or modify them
RegistryKey in the Microsoft.Win32 namespace in
'. NET, registry,registryhive is used to manipulate the registry
' |______ scanremoteregister ___________|
'| Coypright WGSCD (c) 2005 |
'| qq:153964481 e-mail:wgscd@126.com |
'| blog:http://blog.csdn.net/wgsnet |
'|______________________________________|
Dim Treev as New TreeView
Dim subnode as New TreeNode
Dim Treen as New TreeNode
Function Openremoteregister (ByVal remotebasekey As String, ByVal ComputerName as String) as String
Dim subkey as Microsoft.Win32.RegistryKey
Dim k as Microsoft.Win32.RegistryKey = Microsoft.Win32.RegistryKey.OpenRemoteBaseKey (Remotebasekey, Net.Dns.GetHostByName (ComputerName). HostName)
TreeV.Nodes.Add (Net.Dns.GetHostByName (ComputerName). HostName) ' Add computer name to TreeView
treeV.Nodes.Add (k.name)
Dim s as String
for each s in K.getsubkeynames ' gets the subkey name
TreeN.Nodes.Add (s)
subkey = K.opensubkey (s)
Openkeys (subkey) ' Open subkey/Key
Next
treeV.Nodes.Add (Treen)
End Function
Sub Openkeys (ByVal Key as Microsoft.Win32.RegistryKey)
' K.subkeycount ' gets the number of subkeys
Dim s as String
Dim subkey as Microsoft.Win32.RegistryKey
TREEN.NODES.ADD (Key.name)
If Key.GetSubKeyNames.Length > 0 Then
for each s in Key.getsubkeynames ' gets the subkey name
TreeN.Nodes.Add (s)
Try
subkey = Key.opensubkey (S, False)
Me.Text = s
if s like "*microsoft*" Or "*wgscd*" Then ' Add as search conditions Then ' Add as search conditions
' ADD yor CODE ...
MsgBox (s)
End If
Openkeys (subkey)
Catch ex as Exception
End Try
Next
treeV.Nodes.Add (Treen) ' Adds a registry key to the TreeView
with subkeys
End If
End Sub
Sub Dome ()
Openremoteregister (Microsoft.Win32.RegistryHive.CurrentUser, Net.Dns.GetHostByName ("WGSCD"). HostName) ' Scans CurrentUser items
' "WGSCD" is the name of the remote computer you want to scan, notice that you have the appropriate permissions on the remote computer!
' Openremoteregister (Microsoft.Win32.RegistryHive.LocalMachine, Net.Dns.GetHostByName ("WGSCD"). HostName) ' Scans localmachine items
' Openremoteregister (Microsoft.Win32.RegistryHive.Users, Net.Dns.GetHostByName ("WGSCD"). HostName) ' Scans users item
' Openremoteregister (Microsoft.Win32.RegistryHive.ClassesRoot, Net.Dns.GetHostByName ("WGSCD"). HostName) ' Scans classesroot items
' Openremoteregister (Microsoft.Win32.RegistryHive.CurrentConfig, Net.Dns.GetHostByName ("WGSCD"). HostName) ' Scans currentconfig items
' Openremoteregister (Microsoft.Win32.RegistryHive.DynData, Net.Dns.GetHostByName ("WGSCD"). HostName) ' Scans DynData items
End Sub
Sub scanremoteregistry ()
Dim Mythread as New threading.thread (AddressOf Dome)
Mythread.start ()
End Sub
Sub Addtreeviewtoform () adds the TreeView to the Formss
with Treev
. Width = 400
. Height = 500
End With
Me.Controls.Add (Treev)
End Sub
Call:
scanremoteregistry ()