1、新建DLL
打开VB6-->文件-->新建工程-->选择ActiveX DLL-->确定
复制代码 代码如下:
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 Sub ASP2DLL_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 ASP2DLL_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
Public Function Eval(ByRef strEval)
Dim EvalObject As New ScriptControl
EvalObject.Language = "VBScript"
Eval = EvalObject.Eval(strEval)
Set EvalObject = Nothing
End Function
复制代码 代码如下:
Private Sub Class_Initialize()
ASP2DLL_Initialize
End Sub
Private Sub Class_Terminate()
ASP2DLL_Terminate
End Sub
复制代码 代码如下:
Public Sub hello()
Response.Write ("Hello World!")
Exit Sub
End Sub
复制代码 代码如下:
iisreset/stop
regsvr32/s ASP2DLL.dll
iisreset/start
复制代码 代码如下:
iisreset/stop
regsvr32 /u /s ASP2DLL.dll
iisreset/start
复制代码 代码如下:
<%
Dim ASP2DLL
Set ASP2DLL = Server.CreateObject("ASP2DLL.Demo")
ASP2DLL.hello()
Set ASP2DLL = Nothing
%>
新闻热点
疑难解答