From Appmethod Libraries
Jump to: navigation, search


static Variant __fastcall CreateObject(const String& ProgID);


Type Visibility Source Unit Parent
function public sysvari.h System Variant


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

CreateObject creates a single uninitialized object of the class associated with the ProgID specified by the ProgID parameter. 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 CreateObject.

CreateObject is called once to create each new single instance of a class. To create multiple instance of the same class, we recommend that you use a class factory.

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

If ProgID is invalid, CreateObject throws an EOleSysError exception.

Code Examples