RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
ComObj.CreateComObject Function

Instantiates a single instance of a COM object.

Pascal
function CreateComObject(const ClassID: TGUID): IUnknown;
C++
IUnknown CreateComObject(const TGUID ClassID);

CreateComObject creates a single uninitialized object of the class associated with the CLSID specified by the ClassID parameter. CreateComObject is used to create an object of a specified type when the CLSID is known, and when the object is on a local or in-proc server.

Note: In Delphi code, CreateComObject is called once to create each new single instance of a class. To create multiple instance of the same class it is recommended to use a class factory.
CreateComObject returns a reference to the interface to be used to communicate with the object. For CreateComObject this interface is of type IUnknown. To create OLE objects that return references to the IDispatch interface, use CreateOleObject.
Tip: If the interface returned by CreateCOMObject is assigned to a Variant, you can release the interface by assigning the Unassigned constant to that Variant.
 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!