From RAD Studio API Documentation
Jump to: navigation, search


function CreateComObject(const ClassID: TGUID): IUnknown;


extern DELPHI_PACKAGE System::_di_IInterface __fastcall CreateComObject(const GUID &ClassID);


Type Visibility Source Unit Parent
function public
System.Win.ComObj System.Win.ComObj


Instantiates a single instance of a COM object.

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.

See Also