ASP calls VB writing DLL
/ ** Author: Chi Qin-Email: cqq1978@Gmail.com Description: Asp own several large objects provided in some cases and can not meet our needs at this time we need to prepare yourself assembly, and then call in the final in Asp Modification: 2004-10-02 ** /
When you use ASP to do a website, it is often found that some functions are unable to implement the ASP itself, it must be used in components of the third party. For example, send email, file upload, and more.
Today, take VB as an example, simple to make our own components, then call it in the ASP.
First, open VB, in the new engineering type, we select ActiveX DLL, if your component needs the interface, you can also select the ActiveX control.
The system then generates a class module Class1 by default, and we can change to the name we need, such as FirstClass. Explain that when we call the object in the ASP, we wrote this: set obj = server.createObject ("adoDb.connection") We all know that AdoDB is an object library, there are many objects in it, and the connection is among them. An object. So, we create class modules above, actually the specific object, is the same as the status of Connection.
Below, we can write the code for the object firstclass, which is the function of our function. We write a very simple way to return a string
Public function getversion () AS STRING GETVERSION = "My First DLL, Version 1.0" End Function
After writing, we must determine the name of the class library, just like the ADODB above. We can see a project name in the engineering menu and engineering attribute interface. The default is "Engineering 1", which is where we need to modify, such as we change to CQQLIB
Ok, generate the corresponding DLL, this time the system will automatically register this component into the system. If you want to use on other computers, you need to register first, just enter regsvr32 a.dll in the command line.
Below, let's take a look at how to use this DLL in the ASP, very simple: <% set obj = server.createObject ("cqqlib.firstclass") response.write obj.getversion%> You can see the output, that is, " My first DLL, version 1.0 "