4。編寫(xiě)代碼:
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 "我是藍(lán)色理想的老農(nóng),您好"
End Sub
' 釋放內(nèi)部對(duì)象 Public Sub OnEndPage() Set Application = Nothing Set Request = Nothing Set Response = Nothing Set Server = Nothing Set Session = Nothing
Set Context = Nothing End Sub
其中,除10處,其他都是必須的. 10處是我們自己要表現(xiàn)的程序.
ctrl+s保存在d:\mylib\cjjer.cls
在把工程保存為d:\mylib\bi.vbp
5 。編譯,注冊(cè)成dll:
點(diǎn)擊生成bi.dll
沒(méi)啥警告的話那就ok了,路徑保存在d:\mylib\bi.dll.
然后開(kāi)始--------->運(yùn)行-->
regsvr32 d:\mylib\bi.dll
這就注冊(cè)成功了.
6。使用bi.dll:
新建asp文件,輸入:
<% Dim bicjjer Set bicjjer=Server.CreateObject("bi.cjjer") bicjjer.showsuc() %>
瀏覽器,預(yù)覽,顯示如下:
注意:對(duì)已經(jīng)存在的組建名稱(chēng)或這修改了dll文件,必須先停止IIS,再重啟注冊(cè)使用,否則會(huì)一直在原來(lái)的基礎(chǔ)上.
另外補(bǔ)充一點(diǎn):生成的dll文件不注冊(cè)到服務(wù)器也可以使用:
<% @ language="vbscript" %> <!--METADATA TYPE="typelib" FILE="e:\web\web\asp\bi\bi.dll"--> <% Dim bicjjer Set bicjjer=Server.CreateObject("bi.cjjer") bicjjer.showsuc() %>
這絕對(duì)是個(gè)好消息,有人說(shuō)這個(gè)沒(méi)什么價(jià)值,那我說(shuō)"您還是固陋寡聞或者您技術(shù)高的藐視dll...",哈哈哈,當(dāng)然是玩笑了,注意,METADATA的file路徑是絕對(duì)的物理路徑,否則無(wú)法裝載.
經(jīng)典論壇討論帖: http://www.95time.cn/bbs/NewsDetail.asp?id=2445081
出處:藍(lán)色理想
責(zé)任編輯:moby
上一頁(yè) asp編譯成dll-圖形化教程 [1] 下一頁(yè)
◎進(jìn)入論壇網(wǎng)絡(luò)編程版塊參加討論
|