CreateObject method Creates
COM object as specified (see below).
Syntax:
Set o = object.CreateObject( objIDString [, flags])
Parameters:
objIDString - A string containing ProgID, ClassID, DLL
path + ClassID, File name etc. Depending on the value different
mechanisms will be attempted. The string can follow one of the
following schemes:
ClassID - A form like {238DF0CC-1982-4D2A-9773-22795F358304}.
The method will attempt standard COM techniques (if not forbidden by
the flags - see below) and if the object is not registered the
newobjectspack1.dll will be tried - if the ClassID matches some of
the classes in it the object will be created.
ProgID - A form like Company.ClassName or Company.Category.ClassName.
The usual way COM objects are created from scripting applications.
This will succeed only if the object is registered in the system
registry.
File name - Form like this C:\mycomponents\composite_definition.def.
Method will see if the file is a definition of a composite
object and will try to create it.
DLL File + ClassID - Form like this C:\dlls\someCOMDll.DLL{238DF0CC-1982-4D2A-9773-22795F358304}
The method will attempt to load the DLL and create an object
of the class specified by the ClassID after the DLL name.
Internal Alias - An alias of one of the classes in the
newobjectspack1.dll. Teh following aliases are currently defined:
flags - optional flags which can be used to forbid
some of the supported mechanisms. Specifying flags may improve the
application performance if the application creates objects in rapid
rate. The flags supported are:
&H01 |
Try the standard COM techniques first |
&H10 |
Do not use ActiveX Pack1 aliases |
&H20 |
Do not try as composite definition files |
&H40 |
Do not try the standard COM techniques |
&H80 |
Do not try direct DLL |
Examples:
Set cr = Server.CreateObject("newObjects.utilctls.Pack1Creator")
' Typical COM way
Set o = cr.CreateObject("newObjects.utilctls.SFShellLink")
' By alias
Set o = cr.CreateObject("SFShellLink")
' By alias but also flags are used to help the method determine what to do
Set o = cr.CreateObject("SFShellLink",&HE0)
' Direct creation from a DLL
Set o = cr.CreateObject(Server.MapPath("DLLS\newobjectspack1.dll{70BD6BA6-C316-4CD5-9E95-A5BEA443ABAC}")
Remarks:
The flags can be used also to guarantee no confusion will occur if
there is a registered COM class with ProgID matching an internal
object alias. This is most likely impossible but can be done with some
of the development tools (in C++ you are free to specify whatever you
want for ProgID) so a precaution will not be a mistake.
If the class is not registered in the registry or is registered as
"Both" it will be created in the same COM apartment where
the Pack1Creator is. This gives the application more control over the
creation process than usual. For example COMApartment object uses this
to allow the application create objects in the newly created
apartment. So having a Pack1Creator object in a given context you can
create other objects in the same context through it.
See also the remarks for the CreateObjectFromDLL
if you are going to use direct DLL creation.
Applies to: Pack1Creator
object
|