用
VB把ASP代码写成DLL
1、在菜单选工程--引用--在弹出的窗口选
"Microsoft Active Server Pages Object Libray"
2、工程名,类名写好。。
3、 先写这些东西
Private MyScriptingContext As ScriptingContext
Private MyApplication As Application
Private MyRequest As Request
Private MyResponse As Response
Private MyServer As Server
Private MySession As Session
Dim szSQL, lzname(), lzid()
Public TotalPages
Public Sub OnStartPage(PassedScriptingContext As ScriptingContext)
Set MyScriptingContext = PassedScriptingContext
Set MyApplication = MyScriptingContext.Application
Set MyRequest = MyScriptingContext.Request
Set MyResponse = MyScriptingContext.Response
Set MyServer = MyScriptingContext.Server
Set MySession = MyScriptingContext.Session
End Sub
Public Sub OnEndPage()
Set MyScriptingContext = Nothing
Set MyApplication = Nothing
Set MyRequest = Nothing
Set MyResponse = Nothing
Set MyServer = Nothing
Set MySession = Nothing
End Sub
'上面这些是固定的。就这样,把ASP的6大对象都放进来了
Function Test(xxx)
MyResponse.Write ("Hello World")
End Function
Public Sub SayHello()
MyResponse.Write ("Hello World")
End Sub
'随你怎么写函数,或者过程了
==============================到此
MyApplication = asp的 Application
MyRequest = asp的 Request
MyResponse = asp的 As Response
MyServer =asp的 Server
MySession =asp的 Session
==============================随你怎么用了
4、把 你的.dll复制到system32目录下,运行regsvr32 你的.dll
注册 =================
5、asp调用
set t =server.CreateObject("textdll.abc")
'创建刚才我们写的DLL对象,textdll是我们上面的的工程名,abc是类的名称
haha=t.TesA()
set t=nothing