把ASP用DLL来写的原因:
1、代码保护
ASP的代码是在交付客户的时候是完全被暴露的。相对的保密性没有。市场上出现了很多对Asp加密的产品,但是在起到保护代码的作用的同时,运行速度被降低了,而且也不便于二次开发和管理。而ActiveX DLL完全可以实现Asp能做的所有工作,而且成品是经过编译的DLL文件,这样只把成品交付客户即可,自己的技术得到了很好的保护。

2、运行高效
这一点单凭滔滔不绝的说是没用的!
下面的代码可以证明这个!

先来看看针对用VB来实现的一些必须的代码:

用VB ActiveX DLL编写ASP的一些基本资料' ------------ 用ActiveX DLL来写ASP --------------------
用VB ActiveX DLL编写ASP的一些基本资料

用VB ActiveX DLL编写ASP的一些基本资料
' Author:任兀
用VB ActiveX DLL编写ASP的一些基本资料'
 Nick Name:DSclub
用VB ActiveX DLL编写ASP的一些基本资料'
 CSDN: dsclub(兀儿)
用VB ActiveX DLL编写ASP的一些基本资料'
 WebLog:www.cnblogs.com/dsclub
用VB ActiveX DLL编写ASP的一些基本资料'
 QQ:9967030
用VB ActiveX DLL编写ASP的一些基本资料

用VB ActiveX DLL编写ASP的一些基本资料
用VB ActiveX DLL编写ASP的一些基本资料
用VB ActiveX DLL编写ASP的一些基本资料
' |||||||||||||||||||||  说 明  |||||||||||||||||||||||
用VB ActiveX DLL编写ASP的一些基本资料'
用VB ActiveX DLL编写ASP的一些基本资料'
 必须要执行的工作:
用VB ActiveX DLL编写ASP的一些基本资料'
 1、引用 MicroSoft Active Server Page Object Library组件
用VB ActiveX DLL编写ASP的一些基本资料'
 2、添加 OnStartPage OnEndPage 事件
用VB ActiveX DLL编写ASP的一些基本资料'
 3、OnStartPage事件负责接收 ScriptingContext 对象
用VB ActiveX DLL编写ASP的一些基本资料'
    该对象提供ASP页面环境
用VB ActiveX DLL编写ASP的一些基本资料'
用VB ActiveX DLL编写ASP的一些基本资料'
用VB ActiveX DLL编写ASP的一些基本资料'
||||||||||||||||||||||||||||||||||||||||||||||||||||||
用VB ActiveX DLL编写ASP的一些基本资料

用VB ActiveX DLL编写ASP的一些基本资料
Option Explicit
用VB ActiveX DLL编写ASP的一些基本资料
用VB ActiveX DLL编写ASP的一些基本资料
' ===========================================================
用VB ActiveX DLL编写ASP的一些基本资料

用VB ActiveX DLL编写ASP的一些基本资料
' ------------ 必须的Asp对象 ----------------
用VB ActiveX DLL编写ASP的一些基本资料
Private mContext As ScriptingContext
用VB ActiveX DLL编写ASP的一些基本资料
用VB ActiveX DLL编写ASP的一些基本资料
Private mApplication As Application
用VB ActiveX DLL编写ASP的一些基本资料
Private mResponse As Response
用VB ActiveX DLL编写ASP的一些基本资料
Private mRequest As Request
用VB ActiveX DLL编写ASP的一些基本资料
Private mSession As Session
用VB ActiveX DLL编写ASP的一些基本资料
Private mServer As Server
用VB ActiveX DLL编写ASP的一些基本资料
' ------------------------------------------
用VB ActiveX DLL编写ASP的一些基本资料

用VB ActiveX DLL编写ASP的一些基本资料
' 接收ScriptingContext对象
用VB ActiveX DLL编写ASP的一些基本资料'
 初始化各个ASP对象
用VB ActiveX DLL编写ASP的一些基本资料
Public Sub OnStartPage(PassedScriptContext As ScriptingContext)
用VB ActiveX DLL编写ASP的一些基本资料    
用VB ActiveX DLL编写ASP的一些基本资料    
' Asp运行环境对象
用VB ActiveX DLL编写ASP的一些基本资料
    Set mContext = PassedScriptContext
用VB ActiveX DLL编写ASP的一些基本资料    
用VB ActiveX DLL编写ASP的一些基本资料    
' Asp 五大对象
用VB ActiveX DLL编写ASP的一些基本资料
    Set mApplication = mContext.Application
用VB ActiveX DLL编写ASP的一些基本资料    
Set mRequest = mContext.Request
用VB ActiveX DLL编写ASP的一些基本资料    
Set mResponse = mContext.Response
用VB ActiveX DLL编写ASP的一些基本资料    
Set mServer = mContext.Server
用VB ActiveX DLL编写ASP的一些基本资料    
Set mSession = mContext.Session
用VB ActiveX DLL编写ASP的一些基本资料    
用VB ActiveX DLL编写ASP的一些基本资料
End Sub
用VB ActiveX DLL编写ASP的一些基本资料
用VB ActiveX DLL编写ASP的一些基本资料
用VB ActiveX DLL编写ASP的一些基本资料
' 释放内部对象
用VB ActiveX DLL编写ASP的一些基本资料
Public Sub OnEndPage()
用VB ActiveX DLL编写ASP的一些基本资料    
Set mApplication = Nothing
用VB ActiveX DLL编写ASP的一些基本资料    
Set mRequest = Nothing
用VB ActiveX DLL编写ASP的一些基本资料    
Set mResponse = Nothing
用VB ActiveX DLL编写ASP的一些基本资料    
Set mServer = Nothing
用VB ActiveX DLL编写ASP的一些基本资料    
Set mSession = Nothing
用VB ActiveX DLL编写ASP的一些基本资料    
用VB ActiveX DLL编写ASP的一些基本资料    
Set mContext = Nothing
用VB ActiveX DLL编写ASP的一些基本资料
End Sub
用VB ActiveX DLL编写ASP的一些基本资料
' ===========================================================


好了,我认为注释写的还算可以啦……


直接证明速度上的优势啦,KKK~~~~~~~~~~

在VB里添加:
用VB ActiveX DLL编写ASP的一些基本资料Public Sub Count()
用VB ActiveX DLL编写ASP的一些基本资料
Dim i As Long
用VB ActiveX DLL编写ASP的一些基本资料
Dim j As Long
用VB ActiveX DLL编写ASP的一些基本资料
用VB ActiveX DLL编写ASP的一些基本资料
For i = 0 To 10000000
用VB ActiveX DLL编写ASP的一些基本资料    j 
= j + 2
用VB ActiveX DLL编写ASP的一些基本资料
Next i
用VB ActiveX DLL编写ASP的一些基本资料
用VB ActiveX DLL编写ASP的一些基本资料mResponse.Write j
用VB ActiveX DLL编写ASP的一些基本资料
End Sub


再在Asp里写:
<%
<% Response.Write "
" & Now() & "
" Response.Flush Set obj = server.CreateObject("DSclub.Imgcompose") obj.Count Set obj = Nothing Response.Write "
" & Now() & "
" Response.Flush %>Response.Write "<br/>" & Now() & "<br/>"
Response.Flush

Set obj = server.CreateObject("DSclub.Imgcompose")
obj.Count
Set obj = Nothing

Response.Write "<br/>" & Now() & "<br/>"
Response.Flush
%>


同样的代码功能用纯Asp来实现一下:

<%@ Language=VBScript %>
<%
Dim i,j

Response.Write "<br>" & Now() & "<br>"
Response.Flush


For i=0 to 10000000
 j = j+2
next


Response.Write j

Response.Write "<br>" & Now()  & "<br>"
Response.Flush
%>
<%@ Language=VBScript %><% Dim i,j Response.Write "
" & Now() & "
" Response.Flush For i=0 to 10000000 j = j+2 next Response.Write j Response.Write "
" & Now() & "
" Response.Flush %>

分别运行两个页面看结果:
靠,都不想说了
DLL的那个页面结果:
2004-7-10 15:41:48
20000002
2004-7-10 15:41:48

纯Asp的那个页面结果:
2004-7-10 15:41:38
20000002
2004-7-10 15:41:42


我的机器是
P42.8c 512M的
OS:windos XP

竟然差了这么多!!!

<% Response.Write "
" & Now() & "
" Response.Flush Set obj = server.CreateObject("DSclub.Imgcompose") obj.Count Set obj = Nothing Response.Write "
" & Now() & "
" Response.Flush %><% Response.Write "
" & Now() & "
" Response.Flush Set obj = server.CreateObject("DSclub.Imgcompose") obj.Count Set obj = Nothing Response.Write "
" & Now() & "
" Response.Flush %><% Response.Write "
" & Now() & "
" Response.Flush Set obj = server.CreateObject("DSclub.Imgcompose") obj.Count Set obj = Nothing Response.Write "
" & Now() & "
" Response.Flush %><% Response.Write "
" & Now() & "
" Response.Flush Set obj = server.CreateObject("DSclub.Imgcompose") obj.Count Set obj = Nothing Response.Write "
" & Now() & "
" Response.Flush %><% Response.Write "
" & Now() & "
" Response.Flush Set obj = server.CreateObject("DSclub.Imgcompose") obj.Count Set obj = Nothing Response.Write "
" & Now() & "
" Response.Flush %><% Response.Write "
" & Now() & "
" Response.Flush Set obj = server.CreateObject("DSclub.Imgcompose") obj.Count Set obj = Nothing Response.Write "
" & Now() & "
" Response.Flush %>

相关文章:

  • 2022-12-23
  • 2021-11-12
  • 2022-12-23
  • 2021-08-16
  • 2021-10-08
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案