1、打开您的Microsoft Visual Basic,新建工程ActiveX DLL 2、修改工程名(如hbwl)和类模块的名称(如class) 3、增加到引用asp:点击工程--引用,然后选择其中的
 Microsoft Active Server Pages Object Library Microsoft ActiveX Data Objects 2.8 Library Microsoft ActiveX Data Objects Recordset 2.8 library 4、编写代码: Option Explicit Private Context As ScriptingContext Private Application As Application Private Response As Response Private Request As Request Private Session As Session Private Server As Server
Public Sub OnStartPage(PassedscriptContext As ScriptingContext) Set Context = PassedscriptContext Set Application = Context.Application Set Request = Context.Request Set Response = Context.Response Set Server = Context.Server Set Session = Context.Session End Sub
' 释放内部对象 Public Sub OnEndPage() Set Application = Nothing Set Request = Nothing Set Response = Nothing Set Server = Nothing Set Session = Nothing Set Context = Nothing End Sub
Public Sub showsuc() Response.Write "红宝网络欢迎您" End Sub
其中,除上面的showsuc过程外,其他都是必须的。showsuc过程是我们自己要表现的程序. 函数格式如下: Public Function dw() As String dw = "红宝网络" End Function
ctrl+s保存在d:\mylib\class.cls 在把工程保存为d:\mylib\hbwl.vbp
5 、编译,注册成dll: 点击生成hbwl.dll,没啥警告的话那就ok了,路径保存在d:\mylib\hbwl.dll 然后开始-->运行-->regsvr32 d:\mylib\hbwl.dll 这就注册成功了。
6、使用hbwl.dll: 新建asp文件,输入: Dim hbwlclass Set hbwlclass=Server.CreateObject("hbwl.class") hbwlclass.showsuc()
注意:对已经存在的组建名称或这修改了dll文件,必须先停止IIS,再重启注册使用,否则会一直在原来的基础上。 |