Use VB ActiveX DLL to compile some basic ASP documents

Source: Internet
Author: User

The reason for writing ASP Using DLL:
1,CodeProtection
ASP code is completely exposed when delivered to customers. Relatively confidential. There are many ASP-encrypted products on the market. However, while protecting code, the operation speed is reduced and it is not easy for secondary development and management. ActiveX dll can fully implement all the work that ASP can do, and the finished product is a compiled DLL file, so that only the finished product can be delivered to the customer, and its own technology has been well protected.

2. Efficient operation
It is useless to talk about this!
The following code proves this!

Let's take a look at some of the necessary Code implemented using VB:

' ------------ Use ActiveX DLL to write ASP --------------------

' Author: Ren Wu
' Nick name: dsclub
' Csdn: dsclub (wuer)
' Weblog: www.cnblogs.com/dsclub
' QQ: 9967030



' | Description | |
'
' Required tasks:
' 1. reference the Microsoft Active Server Page Object Library component
' 2. Add an onstartpage onendpage event
' 3. The onstartpage event is responsible for receiving the scriptingcontext object.
' This object provides an ASP page Environment
'
'
' | |

Option   Explicit

' ========================================================== ==============================

' ------------ Required ASP object ----------------
Private Mcontext As Scriptingcontext

Private Mapplication As Application
Private Mresponse As Response
Private Mrequest As Request
Private Msession As Session
Private Mserver As Server
' ------------------------------------------

' Receive the scriptingcontext object
' Initialize ASP objects
Public   Sub Onstartpage (passedscriptcontext As Scriptingcontext)

' ASP running environment object
Set Mcontext = Passedscriptcontext

' Five ASP objects
Set Mapplication = Mcontext. Application
Set Mrequest = Mcontext. Request
Set Mresponse = Mcontext. Response
Set Mserver = Mcontext. Server
Set Msession = Mcontext. Session

End sub


' Release internal objects
Public   Sub Onendpage ()
Set Mapplication =   Nothing
Set Mrequest =   Nothing
Set Mresponse =   Nothing
Set Mserver =   Nothing
Set Msession =   Nothing

Set Mcontext =   Nothing
End sub
' ========================================================== ==============================

Okay, I think it's okay to write comments ......

Prove the speed advantage directly. KKK ~~~~~~~~~~

Add the following in VB: Public   Sub Count ()
Dim I As   Long
Dim J As   Long

For I =   0   To   10000000
J = J +   2
Next I

Mresponse. Write J
End sub

Then write in ASP:
<%
"& 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
%>

The same Code functions are implemented using ASP only:

<% @ 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
%>
"& Now ()&"
"
Response. Flush

For I = 0 to 10000000
J = J + 2
Next

Response. Write J

Response. Write"
"& Now ()&"
"
Response. Flush
%>

Run two pages to view the results:
You don't want to talk about it anymore.
The page result of DLL:
2004-7-10 15:41:48
20000002
2004-7-10 15:41:48

The result of the pure ASP page:
2004-7-10 15:41:38
20000002
2004-7-10 15:41:42

My machine is
Of p42.8c 512m
OS: ipvs XP

So much difference !!!

"& Now ()&"
"
Response. Flush

Set OBJ = server. Createobject ("dsclub. imgcompose ")
OBJ. Count
Set OBJ = nothing

Response. Write"
"& Now ()&"
"
Response. Flush

%> "& Now ()&"
"
Response. Flush

Set OBJ = server. Createobject ("dsclub. imgcompose ")
OBJ. Count
Set OBJ = nothing

Response. Write"
"& Now ()&"
"
Response. Flush

%> "& Now ()&"
"
Response. Flush

Set OBJ = server. Createobject ("dsclub. imgcompose ")
OBJ. Count
Set OBJ = nothing

Response. Write"
"& Now ()&"
"
Response. Flush

%> "& Now ()&"
"
Response. Flush

Set OBJ = server. Createobject ("dsclub. imgcompose ")
OBJ. Count
Set OBJ = nothing

Response. Write"
"& Now ()&"
"
Response. Flush

%> "& Now ()&"
"
Response. Flush

Set OBJ = server. Createobject ("dsclub. imgcompose ")
OBJ. Count
Set OBJ = nothing

Response. Write"
"& Now ()&"
"
Response. Flush

%> "& Now ()&"
"
Response. Flush

Set OBJ = server. Createobject ("dsclub. imgcompose ")
OBJ. Count
Set OBJ = nothing

Response. Write"
"& Now ()&"
"
Response. Flush

%>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.