Advanced COM CreateObjectFromDLL method
CreateObjectFromDLL method

Creates a COM object from a given DLL and ClassID. CreateObject can be used instead as this method is called internally when needed.

Syntax:

Set o = object.CreateObjectFromDLL( dll, ClassID)

Parameters:

dll - Full physical name of a DLL

ClassID - The ClassID (not ProgID) of a COM class implemented by the DLL.

Remarks:

As the creation of an object from a DLL is a specific operation this method can be used instead of CreateObject when needed.

The DLL is loaded and then an attempt is made to create an object of the class with the given ClassID. If it is successful the DLL remains loaded. As the operation bypasses the typical COM API the DLL will remain in memory to ensure the object's functionality - i.e. it will not be unloaded when all the objects from it are released. Most hosts try to keep the DLLs in memory because of different reasons so this is not a problem unless you want to replace the DLL - then you will need to stop and replace the DLL and restart the application, but as we mentioned above today this is true for the most applications because of other reasons.

The object is created in the same context/ COM apartment where the Pack1Creator object resides. Make sure the context is appropriate for the created object. For example the object may require single-threaded apartment - then COMApartment should be used to guarantee that.

Applies to: Pack1Creator object

newObjects Copyright 2001-2006 newObjects [ ]