论坛交流
首页办公自动化| 网页制作| 平面设计| 动画制作| 数据库开发| 程序设计| 全部视频教程
应用视频: Windows | Word2007 | Excel2007 | PowerPoint2007 | Dreamweaver 8 | Fireworks 8 | Flash 8 | Photoshop cs | CorelDraw 12
编程视频: C语言视频教程 | HTML | Div+Css布局 | Javascript | Access数据库 | Asp | Sql Server数据库Asp.net  | Flash AS
当前位置 > 文字教程 > Asp.net教程
Tag:静态页面,treeview,gridview,repeater,dataset,sqldatareader,ado.net,上传,三层,ajax,xml,留言本,新闻发布,商城,注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,触发器,socket,form认证,登录,视频教程

.NET扫描远程计算机注册表

文章类别:Asp.net | 发表日期:2008-10-5 22:12:28

    '有时候需要扫描远程计算机的注册表,判断一些键值项的存在与否,或者修改他们
    '.NET 里的Microsoft.Win32命名空间下的RegistryKey ,Registry,RegistryHive就是用来操作注册表的

    '|______  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) '将计算机名添加到TreeView
        treeV.Nodes.Add(k.Name)
        Dim s As String
        For Each s In k.GetSubKeyNames '得到子键项Name
            treeN.Nodes.Add(s)
            subkey = k.OpenSubKey(s)
            OpenKeys(subkey) '打开子项/键
        Next
        treeV.Nodes.Add(treeN)
    End Function
    Sub OpenKeys(ByVal Key As Microsoft.Win32.RegistryKey)
        'k.SubKeyCount'得到子键项数
        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 '得到子键项Name
                treeN.Nodes.Add(s)
                Try
                    SubKey = Key.OpenSubKey(s, False)

                    Me.Text = s
                    If s Like "*microsoft*" Or s Like "*wgscd*" Then  '加如搜索条件Then '加如搜索条件
                        'ADD YOR CODE ....
                        MsgBox(s)
                    End If
                    OpenKeys(SubKey)
                Catch ex As Exception
                End Try

            Next
            treeV.Nodes.Add(treeN) '将注册表项以子项添加到TreeView

        End If
    End Sub
    Sub dome()
        OpenRemoteRegister(Microsoft.Win32.RegistryHive.CurrentUser, Net.Dns.GetHostByName("wgscd").HostName) '扫描CurrentUser项
        '“wgscd”是你要扫描的远程计算机名,注意,前提是你对“远程计算机”有相应的权限!
        'OpenRemoteRegister(Microsoft.Win32.RegistryHive.LocalMachine, Net.Dns.GetHostByName("wgscd").HostName)’扫描LocalMachine项
        ' OpenRemoteRegister(Microsoft.Win32.RegistryHive.Users, Net.Dns.GetHostByName("wgscd").HostName) '扫描Users项
        ' OpenRemoteRegister(Microsoft.Win32.RegistryHive.ClassesRoot, Net.Dns.GetHostByName("wgscd").HostName) '扫描ClassesRoot项
        'OpenRemoteRegister(Microsoft.Win32.RegistryHive.CurrentConfig, Net.Dns.GetHostByName("wgscd").HostName) '扫描CurrentConfig项
        'OpenRemoteRegister(Microsoft.Win32.RegistryHive.DynData, Net.Dns.GetHostByName("wgscd").HostName) '扫描DynData项
    End Sub
    Sub ScanRemoteRegistry()
        Dim Mythread As New Threading.Thread(AddressOf dome)
        Mythread.Start()
    End Sub
    Sub AddTreeViewToForm() '将TreeView添加到Formss上
        With treeV
            .Width = 400
            .Height = 500
        End With
        Me.Controls.Add(treeV)
    End Sub

调用:

        ScanRemoteRegistry()

视频教程列表
文章教程搜索
 
Asp.net推荐教程
Asp.net热门教程
看全部视频教程
购买方式/价格
购买视频教程: 咨询客服
tel:15972130058