怎么在aspx 页面调用dll
2016-05-15 · 百度知道合伙人官方认证企业
育知同创教育
1【专注:Python+人工智能|Java大数据|HTML5培训】 2【免费提供名师直播课堂、公开课及视频教程】 3【地址:北京市昌平区三旗百汇物美大卖场2层,微信公众号:yuzhitc】
向TA提问
关注
展开全部
在aspx 页面调用dll的方法(以vbscript为例来说明):
<% @ language="vbscript" %>
例:在dll中编译以下代码:
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 showinfo()
Response.Write "asp编译DLL,不需要服务器上注册组件!"
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放在了 d:/myweb/test.dll那么需要服务器注册:regsvr32 d:/myweb/test.dll
在ASP中使用时:
<%
Dim newtest
Set newtest=Server.CreateObject("类模块名称")
newtest.showinfo()
%>
在不注册组件的情况下,通常这样来使用:
<% @ language="vbscript" %>
<!--METADATA TYPE="typelib" FILE="d:/myweb/test.dll"-->
<%
Dim newtest
Set newtest=Server.CreateObject("类模块名称")
newtest.showinfo()
%>
以上用法就可以达到立即调用的目的。
为了保护程序代码的安全,编译DLL是个不错的选择。
<% @ language="vbscript" %>
例:在dll中编译以下代码:
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 showinfo()
Response.Write "asp编译DLL,不需要服务器上注册组件!"
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放在了 d:/myweb/test.dll那么需要服务器注册:regsvr32 d:/myweb/test.dll
在ASP中使用时:
<%
Dim newtest
Set newtest=Server.CreateObject("类模块名称")
newtest.showinfo()
%>
在不注册组件的情况下,通常这样来使用:
<% @ language="vbscript" %>
<!--METADATA TYPE="typelib" FILE="d:/myweb/test.dll"-->
<%
Dim newtest
Set newtest=Server.CreateObject("类模块名称")
newtest.showinfo()
%>
以上用法就可以达到立即调用的目的。
为了保护程序代码的安全,编译DLL是个不错的选择。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询