用VB新建一个ActiveX DLL项目
工程 - 引用 - “Microsoft Active Server Pages Object”对象库
封装以下代码:
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 "我是Action,您好"
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
注册DLL:开始 - 运行 - regsvr32 xxx.dll
ASP调用
<% @ language="vbscript" %>
<%
Dim bicjjer
Set bicjjer=Server.CreateObject("工程名.类名")
bicjjer.showsuc()
%>
PS:整个过程没什么难度,自己的代码放在SUB里就行。。
我一直弄不成功是因为没有引用对象库,这是关键,不然无法生成DLL。