asp封裝為dll
作者:佚名 時間:2012-04-17 分享到:
1 。打開您的Microsoft Visual Basic:
點擊確定,以下就按照藍色的數字步驟.
2 。修改工程名和類模塊的名稱:
點3,把4改成bi,再點5:
6處改成cjjer.
3。增加到引用asp:
點擊引用,然后選擇其中的Microsoft Active Server Pages Object Library.
點9確定.
4。編寫代碼:
其中,除10處,其他都是必須的.
10處是我們自己要表現的程序.
ctrl+s保存在d:\mylib\cjjer.cls
在把工程保存為d:\mylib\bi.vbp
5 。編譯,注冊成dll:
點擊生成bi.dll
沒啥警告的話那就ok了,路徑保存在d:\mylib\bi.dll.
然后開始--------->運行-->
regsvr32 d:\mylib\bi.dll
這就注冊成功了.
6。使用bi.dll:
新建asp文件,輸入:
<%
Dim bicjjer
Set bicjjer=Server.CreateObject("bi.cjjer")
bicjjer.showsuc()
%>
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 "我是linksj.com"
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