国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設計 > 正文

在ASP頁里面注冊DLL的VBScript CLASS

2019-11-18 20:17:04
字體:
供稿:網(wǎng)友
-----------------------------------------------ROOT1---------------------------------------

*******************************************************************************************
*使用本CLASS可以管理并在asp頁里面注冊你的DLL
*本CLASS在WIN 2K上測試通過
*注:使用本CLASS需要先建立一個xml文件。文件如下.打開記事本將如下3行存為*.XML文件
*
*    <?xml version="1.0" encoding="gb2312" standalone="yes"?>
*    <Dll列表>
*    </Dll列表>
*
*------------------------------------------------------------------------------------------
*范例:
*    dim objRegsvr32
*    set objRegsvr32 = new Regsvr32
*    with objRegsvr32
*        if .LoadXml("../MyDll.xml") then
*            call Response.Write("XML文件加載錯誤")
*            set objRegsvr32 = nothing
*            Response.End
*        end if
*        select case .AddNode("F:/web/cw31072/dll/test/MyClass.dll" , true) '添加新條目并注冊DLL
*            case 1
*                call Response.Write("條目已經(jīng)添加進XML文件!并成功注冊DLL啦!")
*            case 0
*                call Response.Write("條目已經(jīng)添加進XML文件!但注冊DLL時失敗!")
*            case -1
*                call Response.Write("XML文件里已經(jīng)有該條目!該DLL也已經(jīng)注冊的了!")
*        end select
*        ..........................
*    end with
*            
*    '本CLASS非常簡單,里面還有些方法,我就不舉例了,看看就知道了。日后你可以打開
*    '該XML文件看你曾經(jīng)注冊過和待注冊的DLL列表。
*    'XML文件里每個條目如下:<Dll 是否已經(jīng)注冊="1">F:/web/cw31072/dll/test/MyClass.dll</Dll>
*    'F:/web/cw31072/dll/test/MyClass.dll就是你DLL文件的路徑
*    '是否已經(jīng)注冊="1"就是該DLL已經(jīng)注冊過,=“0”就是還沒有注冊呢!
*******************************************************************************************

Class Regsvr32

    PRivate s_objXml
    private s_objNodeRoot
    private s_strXmlPath
    private s_strAttributeName
    
    '------------------------------------
    '目的:    加載DLL配置xml文件
    '參數(shù):    XML文件地址
    '返回:    加載失敗就返回TRUE
    '------------------------------------    
    public function LoadXml(strPath)
        set s_objXml = CreateObject("MSXML2.DOMdocument")
        s_objXml.async = false
        s_objXml.load(strPath)
        if s_objXml.parseError.errorCode <> 0 then
            set s_objXml = nothing
            LoadXml = true
            exit function
        end if
        set s_objNodeRoot = s_objXml.documentElement
        s_strXmlPath = strPath
        s_strAttributeName = "是否已經(jīng)注冊"
    end function
    
    '---------------------------------------------
    '目的:    添加一個DLL項目
    '參數(shù):    strPath:    DLL文件地址
    '          blnReg:    添加后是否將其注冊
    '返回:    如果要求添加后注冊,注冊成功就返回1,注冊失敗返回0,已經(jīng)有該項目并注過冊就返回-1
    '---------------------------------------------
    public function AddNode(strPath , blnReg)
        dim objNewNode
        dim strStart
        dim objNode
        strStart = "0"
        set objNode = SelectNode(strPath)
        if objNode is nothing then
            if Reg(strPath , true) then
                strStart = "1"
                AddNode = true
            else
                AddNode = false
            end if
            set objNewNode = s_objXml.createElement("Dll")
            call objNewNode.setAttribute(s_strAttributeName , strStart)
            objNewNode.Text = strPath
            call s_objNodeRoot.appendChild(objNewNode)
            call s_objXml.save(s_strXmlPath)
        else
            if blnReg then
                if objNode.Attributes.getNamedItem(s_strAttributeName).nodeValue = "1" then
                    AddNode = true
                else
                    if Reg(strPath , true) then
                        objNode.Attributes.getNamedItem(s_strAttributeName).nodeValue = "1"
                        call s_objXml.save(s_strXmlPath)
                    else
                        AddNode = false
                    end if
                end if
             else
                 AddNode = false
             end if
        end if
    end function
    
    '----------------------------------------
    '目的:    刪除所有已經(jīng)注冊,或者沒注冊的節(jié)點
    '參數(shù):    blnStart:    0=未注冊的,1=已經(jīng)注冊的
    '返回:    執(zhí)行了刪除操作就返回TRUE,否則返回FALSE
    '----------------------------------------
    public function ReAllNode(byVal blnStart)
        dim objNode
        dim blnIsChange
        blnStart = CStr(blnStart)
        for each objNode in s_objNodeRoot.childNodes
            if objNode.Attributes.getNamedItem(s_strAttributeName).nodeValue = blnStart then
                call s_objNodeRoot.removeChild(objNode)
                blnIsChange = true
            end if
        next
        if blnIsChange then
            ReAllNode = true
            call s_objXml.save(s_strXmlPath)
        else
            ReAllNode = false
        end if     
    end function
    
    '-----------------------------------------
    '目的:    刪除某一個節(jié)點
    '參數(shù):    節(jié)點內(nèi)容
    '返回:    找不到節(jié)點就返回TRUE
    '-----------------------------------------
    public function ReNode(strPath)
        dim objNode
        set objNode = SelectNode(strPath)
        if objNode is nothing then
            ReNode = true
        else
            call s_objNodeRoot.removeChild(objNode)
            call s_objXml.save(s_strXmlPath)
        end if
    end function
    
    
    '-----------------------------------------
    '目的:    尋找某個節(jié)點
    '參數(shù):    strPath:   節(jié)點內(nèi)容
    '返回:    找到就返回該節(jié)點,找不到就返回nothing
    '-----------------------------------------
    private function SelectNode(ByVal strPath)
        dim objNode
        strPath = UCase(strPath)
        for each objNode in s_objNodeRoot.childNodes
            if UCase(objNode.childNodes.item(0).nodeValue) = strPath then
                Set SelectNode = objNode
                exit function
            end if
        next
        set SelectNode = nothing
    end function
    
    '--------------------------------------------
    '目的:    查看DLL文件列表里某個文件注冊狀態(tài)
    '參數(shù):    該文件路徑
    '返回:    1=已經(jīng)注冊
    '          0=未注冊
    '          -1=找不到該文件
    '--------------------------------------------
    public function CheckDll(strPath)
        dim objNode
        set objNode = SelectNode(strPath)
        if objNode is nothing then
            CheckDll = -1
        else
            CheckDll = Cint(objNode.Attributes.getNamedItem(s_strAttributeName).nodeValue)
        end if
    end function
    
    '--------------------------------------
    '目的:    將所有未注冊的DLL注冊
    '返回:    如果有某個DLL注冊失敗就返回TRUE
    '--------------------------------------
    public function RegAllNode()
        dim objNode
        for each objNode in s_objNodeRoot.childNodes
            if objNode.Attributes.getNamedItem(s_strAttributeName).nodeValue = "0" then
                if Reg(objNode.childNodes.item(0).nodeValue , true) then
                    objNode.Attributes.getNamedItem(s_strAttributeName).nodeValue = 1
                else
                    RegAllNode = true
                end if
            end if
        next
    end function
    
    '-----------------------------------------
    '目的:    注冊DLL
    '參數(shù):    strPath:    要注冊Dll文件路徑
    '          blnLoding:    是否等待注冊完成才繼續(xù)執(zhí)行程序
    '返回:    如果blnLoging=TRUE,注冊成功就返回True
    '-----------------------------------------
    private function Reg(strPath , blnLoding)    
        dim objShell
        set objShell = CreateObject("Wscript.Shell")
        if objShell.Run("regsvr32.exe /s " & strPath , , blnLoding) = 0 then
            Reg = true
        end if
        set objShell = nothing
    end function
    
End Class

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 台中县| 平远县| 内乡县| 和静县| 区。| 苍山县| 托克逊县| 万荣县| 岳阳市| 齐河县| 连江县| 随州市| 同江市| 乌鲁木齐县| 石景山区| 台东市| 宁南县| 旌德县| 普定县| 冀州市| 清涧县| 闽清县| 平乐县| 宁河县| 常山县| 福州市| 通化县| 嘉兴市| 齐齐哈尔市| 读书| 澄江县| 荥经县| 秀山| 桃园县| 潢川县| 平和县| 鹿邑县| 北碚区| 班玛县| 阿瓦提县| 南开区|