. NET Scan remote computer registry

Source: Internet
Author: User
Tags win32
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 ()





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.