System.Win.ComObj.CreateComObject

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function CreateComObject(const ClassID: TGUID): IUnknown;

C++

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

Properties

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

Description

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