ActiveX is a widely used code package proposed by Microsoft to improve the reusability of program code, speeding up the development speed of program projects, generally referred to as "components". In the integrated development environment of VB6, we can see several ActiveX projects:
1, ActiveX EXE
This is the ActiveX / COM server component running outside the process, which means that the process of their runs is different from the client code of the initialization component. Although you can access ActiveX EXE with ASP, it is not recommended to change the IIS library, which allows all executable files to be started by script code running on the server.
2, ActiveX OCXS
These special components are included in the GUI environment to display the additional support required for the host application display and the operation component. You can also put the OCX component on the web page. However, OCX is the application interface, which cannot be created using ASP.
3, ActiveX Document DLL and ActiveX Document EXE
The Active documentation can display the VB form in the OLE file box application, such as IE or Office Binder. But they cannot be applied in ASP.
4, ActiveX DLLS
These ActiveX / COM components and clients operated in the same process. And the ActiveX DLL we have to discuss is the entire component. General Microsoft's additional components and other components provided by other third-party manufacturers are this type of ActiveX DLL, but it is not all written by 肰 b, which can also be developed using VC / Java and so on.
Explore what is ActiveX DLL, we begin to formally write our own ActiveX DLL to implement the same features in the ASP, well known, ASP has built-in Response, Request, Server, Session, Application five objects, in fact, these five built-in objects It is the five ActiveX DLL components initialized in IIS console. Since IIS can initialize these five components for ASP, we can of course directly quote these components directly in our ActiveX DLL to implement our programming, that is, The functionality of accessing the ASP built-in object can be implemented by reference to these components in the VB application.
As long as you have a web server above PWS4 or IIS4, you have a name called "Microsoft Active Server Pages Object", we can reference this object library in the VB's ActiveX DLL application, by reference to this object library, We have gained an object (class): ScriptingContext, this object is also the core object of our entire article. The relationship within the object library is as follows:
Object library class member
Asptypelibrary ScriptingContext Application
REQUEST
Response
Session
Server
Through the above relationship map, we can easily understand the class scriptingcontent. Let's take a concrete example:
1. Create a new ActiveX DLL project using VB6
2. Reference "Microsoft Active Server Pages Object" object library.
3. Create two component events: onstartpage and oneundpage
4. Create a reference to class ScriptingContent in event onstartpage.
5, instantiate the class ScriptingContent.
Test.cls (class implementation)
'Statement of the object
DIM RP As Response
DIM RQ As Request
DIM AP as Application
DIM SR AS Server
DIM SN AS Session
'When the component is created, this event will trigger the event public sub-onstartpage (MySC as scriptingcontent)
'Instantiation of objects
Set rp = mysc.response
Set rq = mysc.request
SET SR = mysc.server
Set ap = mysc.Application
SET SN = mysc.session
rp.write "
ActiveX DLL components have been created!
End Sub
'Trigger this event when the component is destroyed
Public Sub OneendPage ()
Rp.write "
ActiveX DLL components have been destroyed!
"
'Destroying object
Set rp = Nothing
SET RQ = Nothing
SET SR = Nothing
SET AP = Nothing
SET SN = Nothing
End Sub
'Define our own component method
Public Sub HelloWorld ()
Rp.write "
End Sub
This way, we create an ActiveX DLL that can access the ASP built-in object. We named this component project to first, compiling this item in VB to become a DLL file first.dll, and we register this DLL file in the system. Next, we need a simple ASP program that almost no code to call this component:
Test.asp
hEAD>
<%
DIM Testme
'Creating the components we have just compiled, once you create this component, you will be in the Ye Side Output "ActiveX DLL components have been
'created! "
Set testme = server.createObject ("first.test")
'Method of calling components
Testme.helloworld
'Logout assembly, while logging out, it will automatically display "ActiveX DLL component has been destroyed!"
Set testme = Nothing
%>
body>
html>
Through a simple example above, we can see the same functionality using the ActiveX DLL, and the same features that are brought by the code confidentiality and program run are more efficient. ActiveX DLL and Pure ASP have their own advantages and disadvantages, as long as we use both technologies, such as properly encapsulating business logic in ActiveX DLL, or using DLL package technology in a confidential place, you must write efficient Fast web application.
(The above program is passed in VB6 Enterprise Edition, Windows2000 Server Chinese version test passed)