╃苍狼山庄╃╃苍狼山庄╃

Clang出品,
必属精品!

ASP封装成DLL组件

用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。

本原创文章未经允许不得转载 | 当前页面:╃苍狼山庄╃ » ASP封装成DLL组件

评论

文章评论已关闭!