本站推荐

asp代码封装成dll图形化教程

来 源:cjjer.com 作 者:老农 时间:2006-02-25 点击:
loading...
1 :打开您的Microsoft Visual Basic--->

click for full size

点击确定,以下就按照蓝色的数字步骤.

2 :修改工程名和类模块的名称--->

click for full size

点3,把4改成bi,再点5:


click for full size

6处改成cjjer.

3 :增加到引用asp--->

click for full size

点击引用,然后选择其中的Microsoft Active Server Pages Object Library.
click for full size

点9确定.

 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 showsuc()
Response.Write "我是蓝色理想的老农,您好"

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



click for full size

其中,除10处,其他都是必须的.
10处是我们自己要表现的程序.


ctrl+s保存在d:\mylib\cjjer.cls

在把工程保存为d:\mylib\bi.vbp

5 :编译,注册成dll--->

click for full size


点击生成bi.dll

没啥警告的话那就ok了,路径保存在d:\mylib\bi.dll.

然后开始--------->运行-->
regsvr32 d:\mylib\bi.dll


click for full size

click for full size


这就注册成功了.

6 :使用bi.dll--->

新建asp文件,输入:
<%
Dim bicjjer
Set bicjjer=Server.CreateObject("bi.cjjer")
bicjjer.showsuc()
%>

click for full size

浏览器,预览,显示如下:


click for full size


注意:对已经存在的组建名称或这修改了dll文件,必须先停止IIS,再重启注册使用,否则会一直在原来的基础上.

---------------------------------------------
修正:

经过测试,其他机器上编译的dll在另外的机器上先不注册的话无法使用,可能VB在编译成dll的时候已经在注册表里做了手脚--,已经注册了,so我怎么写路径都是虚套子,

asp外部调用dll必须到注册表注册,再次指出.


我对我以上的误导表示强烈的道歉,对所有兴奋过的id表示慰问.

来源:http://www.2ky.cn/h/7/718.htm
转载要求注明来源,请尊重作者版权!

关键字: 

相关内容

会员登陆close X