ASP封装DLL 直接上代码

时间:2021-07-14 12:56:32

ASP转DLL 基本引用类库

OLE Automation

Com+ services Type Library

Microsoft Active Server Pages Object

Microsoft VBScript Regular expression_rs 5.5

microsoft Script control 1.0

如果是SQL数据库还需要另外引入 Microsoft ActiveX Data Objects 2.7 Library

1、模块程序
Public objContext As ObjectContext
Public Application As ASPTypeLibrary.Application
Public Server As ASPTypeLibrary.Server
Public Session As ASPTypeLibrary.Session
Public Response As ASPTypeLibrary.Response
Public Request As ASPTypeLibrary.Request
'Public YSKDLL_Object As Object

Public Sub YSKDLL_Initialize()
On Error Resume Next
Set objContext = GetObjectContext
Set Application = objContext.Item("Application")
Set Server = objContext.Item("Server")
Set Session = objContext.Item("Session")
Set Request = objContext.Item("Request")
Set Response = objContext.Item("Response")
End Sub
Public Sub YSKDLL_Terminate()
On Error Resume Next
Set Application = Nothing
Set Server = Nothing
Set Session = Nothing
Set Request = Nothing
Set Response = Nothing
Set objContext = Nothing
End Sub

2、类程序
Public Conn As ADODB.Connection
Public Rs As ADODB.Recordset
Private Sub Class_Initialize()
YSKDLL_Initialize
End Sub
Private Sub Class_Terminate()
YSKDLL_Terminate
End Sub