RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
Variant::CreateObject Method

Creates an OLE Automation object with the programmatic identifier specified by ProgID and returns it as a System::Variant::Variant.

Pascal
function CreateObject(const ProgID: String&): Variant; static;
C++
static __fastcall Variant CreateObject(const String& ProgID);

System::Variant::CreateObject creates a single uninitialized object of the class associated with the ProgID specified by the ProgID parameter. System::Variant::CreateObject is used to create an object of a specified type when the ProgID 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 System::Variant::CreateObject. 

System::Variant::CreateObject 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. 

System::Variant::CreateObject returns a reference to the identifier of the interface to be used to communicate with the object. For System::Variant::CreateObject, this interface is of type IDispatch

If ProgID is invalid, System::Variant::CreateObject throws an EOleSysError exception. 

 

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