1 。打開(kāi)您的Microsoft Visual Basic:
點(diǎn)擊確定,以下就按照藍(lán)色的數(shù)字步驟.
2 。修改工程名和類(lèi)模塊的名稱(chēng):
點(diǎn)3,把4改成bi,再點(diǎn)5:
6處改成cjjer.
3。增加到引用asp:
點(diǎn)擊引用,然后選擇其中的Microsoft Active Server Pages Object Library.
點(diǎn)9確定.
4。編寫(xiě)代碼:
Option Explicit Private Context As ScriptingContext Public Sub OnStartPage(PassedscriptContext As ScriptingContext) End Sub End Sub ' 釋放內(nèi)部對(duì)象 Set Context = Nothing
Private Application As Application
Private Response As Response
Private Request As Request
Private Session As Session
Private Server As Server
Set Context = PassedscriptContext
Set Application = Context.Application
Set Request = Context.Request
Set Response = Context.Response
Set Server = Context.Server
Set Session = Context.Session
Public Sub showsuc()
Response.Write "我是藍(lán)色理想的老農(nóng),您好"
Public Sub OnEndPage()
Set Application = Nothing
Set Request = Nothing
Set Response = Nothing
Set Server = Nothing
Set Session = 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ú)法裝載.