How do I use COMs in my ASPs?
The Windows' registry is where we gain hard access to COM Components.
Every COM must be registered
in the registry for it to be accessed by IIS (and consequently ASPs).
To register a component, you use a command on the IIS server called REGSVR32. This
command registers component information into the Windows' registry.
Suppose you wanted to register a component called com.dll. At the DOS prompt or
Run... dialogue box in the Windows' Start Menu you would type:
regsvr32 C:\Path\COM.dll
...then press the Enter key. This would be the correct syntax if the component was in the
C:\Path directory. Once the component is registered you should receive a message like the
one below:

Now, the component is ready to use in your ASP pages. However, before you can use it, you
need to know the component's programmatic identifier or ProgID.
For example,
in the following code the "ADODB.Connection" part is refered to as the ProgID:
Set objADO = Server.CreateObject("ADODB.Connection")
When a COM Component is created in Visual Basic, the ProgID is created in the following way:
[Project_Name].[Class_Module_Name]
To use a component in your ASP page simple create a reference to it by using the
ASP Server's CreateObject method:
For example, if the component's ProgID is COM.Component, you would type:
Using VBScript:
Set objCOM = Server.CreateObject("COM.Component")
Using Javascript:
var objCOM = Server.CreateObject("COM.Component")
Remember this: an Object is not a Component (or COM Server). An Object is a reference
or instance of a COM component. In this case, the object objCOM is the reference,
COM is the component's server name (or COM Server), and Component is the component
name (the component module with the COM Server).
|