RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
ComObj.CreateOleObject Function

Instantiates an Automation object.

Pascal
function CreateOleObject(const ClassName: string): IDispatch;
C++
IDispatch CreateOleObject(const AnsiString ClassName);

ComObj

CreateOleObject creates a single uninitialized object of the class specified by the ClassName parameter. ClassName specifies the string representation of the Class ID (CLSID). CreateOleObject 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. Only objects that are not part of an aggregate are created using CreateOleObject.

Note: In Delphi code, CreateOleObject is called once to create each new single instance of a class. To create multiple instance of the same class, using a class factory is recommended.
CreateOleObject returns a reference to the interface that can be used to communicate with the object. For CreateOleObject this interface is of type IDispatch. To create a COM object that does not support an IDispatch interface, use CreateComObject.
Tip: As shown in the example, if the interface returned by CreateOleObject is assigned to a Variant, you can release the interface by assigning the Unassigned constant to that Variant.
 

CreateComObject 

Unassigned 

Connecting to a Server 

Controlling an Automation Server Using a Dispatch Interface

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!