欢迎光临
我们一直在努力

.NET扫描远程计算机注册表-.NET教程,远程及网络应用

建站超值云服务器,限时71元/月

有时候需要扫描远程计算机的注册表,判断一些键值项的存在与否,或者修改他们
    .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()

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » .NET扫描远程计算机注册表-.NET教程,远程及网络应用
分享到: 更多 (0)