教程中国
PHOTOSHOP CS9.0中文版 MAYA 8.5 FOR WINDOWS Corel Painter v9.0 Flash MX2004 中文版 Illustrator cs2 中文版
VC++6.0含sp6 中英文版 VB6.0 +sp6 简体中文版 Borland Delphi 7汉化版 MSDN for vb6.0中文版 Visual Studio 2005简体
教程中国下属 文件存储共享专家BIBIDU.COM 提供大型软件,教材,源码,电影,音乐,图书等下载 更多精品请点此进入
  您目前所在位置: 教程中国 >> 编程基地 >> VBscript >> 在ASP页里面注册DLL的VBScript CLASS RSS订阅
在ASP页里面注册DLL的VBScript CLASS
教程(视频,书籍)下载:  ASP.NET AutoCAD 数据库 C# ASP java photoshop 网页设计 delphi 3dmax Flash C++ VB 张孝祥 实例   更多请进入BIBIDU搜索
IT搜索引擎   
   *******************************************************************************************
*使用本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("条目已经添加进XML文件!并成功注册DLL啦!")
* case 0
* call Response.Write("条目已经添加进XML文件!但注册DLL时失败!")
* case -1
* call Response.Write("XML文件里已经有该条目!该DLL也已经注册的了!")
* end select
* ..........................
* end with

* ’本CLASS非常简单,里面还有些方法,我就不举例了,看看就知道了。日后你可以打开
* ’该XML文件看你曾经注册过和待注册的DLL列表。
* ’XML文件里每个条目如下:<Dll 是否已经注册="1">F:\web\cw31072\dll\test\MyClass.dll</Dll>
* ’F:\web\cw31072\dll\test\MyClass.dll就是你DLL文件的路径
* ’是否已经注册="1"就是该DLL已经注册过,=“0”就是还没有注册呢!
*******************************************************************************************

Class Regsvr32

private s_objXml
private s_objNodeRoot
private s_strXmlPath
private s_strAttributeName

’------------------------------------
’目的: 加载DLL配置xml文件
’参数: 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 = "是否已经注册"
end function

’---------------------------------------------
’目的: 添加一个DLL项目
’参数: strPath: DLL文件地址
’ blnReg: 添加后是否将其注册
’返回: 如果要求添加后注册,注册成功就返回1,注册失败返回0,已经有该项目并注过册就返回-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

’----------------------------------------
’目的: 删除所有已经注册,或者没注册的节点
’参数: blnStart: 0=未注册的,1=已经注册的
’返回: 执行了删除操作就返回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

’-----------------------------------------
’目的: 删除某一个节点
’参数: 节点内容
’返回: 找不到节点就返回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


’-----------------------------------------
’目的: 寻找某个节点
’参数: strPath: 节点内容
’返回: 找到就返回该节点,找不到就返回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文件列表里某个文件注册状态
’参数: 该文件路径
’返回: 1=已经注册
’ 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
’参数: strPath: 要注册Dll文件路径
’ blnLoding: 是否等待注册完成才继续执行程序
’返回: 如果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 

来源:编程技术-十度教育
作者:
关键字:VBScript,CLASS
发表日期:2006-10-18 10:43:16

网页显示有限 阅读全文请下载本文完整版WORD文档

上一篇:纯使用VBScript来实现加密   下一篇:将VB中的CLASS结合到VBscript中来


2008-8-28 7:33:34
本文的相类似文章
  • ASP页面内VBScript和JScript的交互
  • Oracle的X$表系列介绍之-X$KSLLCLASS
  • 设置TOMCAT PATH,CLASSPATH变量
  • 使用vbscript自动配置IIS
  • 利用VBScript实现倒计时
  • 把VB的程序写成VBScript方式放在VBS文件中
  • 让一组相同的控制项有相同的行为(SuperClass)
  • VBScript怎样读取一个目录下的所有文件名到数组
  • VBScript编写“Happy Time欢乐时光”病毒
  • 制作一个可重复使用的数据库class
  • 在学习中进步 在进步中成长 教程中国相随您的成长之路
    华腾联合科技股份有限公司版权所有
    广告联系:Rosibo@163.com