Provides the caller with a pointer to an interface on a class object associated with
a specified CLSID. The CoGetClassObject
function transparently locates, and if necessary, dynamically loads the
executable code required to do this.
when you want to create multiple objects through a class object for which
there is a CLSID in the system registry. You would then call IClassFactory::CreateInstance
to create an uninitialized object. It is not always necessary to go through
this process. To create a single object, call instead the CoCreateInstance
function, which encapsulates connecting to the class object, creating the
instance, and releasing the class object. OLE also provides many other ways to
create an object in the form of numerous helper functions and interface member
functions whose function is to create objects of a single type and provide a
pointer to an interface on that object.
| REFCLSID rclsid,
||//CLSID associated with the class object
| DWORD dwClsContext,
||//Context for running executable code
| LPVOID pvReserved,
||//Must be NULL
| REFIID riid,
| LPVOID * ppv
||//On return, pointer to location of interface pointer
Specifies the CLSID that will associate the correct data and code.
Specifies the context in which the executable code is to be run. For
information on the context values and their use, see the CLSCTX
Reserved for future use. Must be NULL.
Specifies the interface to be used to communicate with the class object. This
interface is almost always IClassFactory
(represented by the riid IID_IClassFactory
Points to where the resulting interface pointer is to be stored.
Location and connection to the specified class object was successful.
CLSID is not properly registered.
The object pointed to by ppv
does not support the interface identified by riid
Error reading the registration database.
In process DLL or handler DLL not found (depends on context).
EXE not found (CLSCTX_LOCAL_SERVER only).
General access failure (returned from LoadLib/CreateProcess
EXE has error in image.
EXE was launched, but it didn't register class object (may or may not have
Out of memory.
One or more arguments are invalid.
An unexpected error occurred.
on the class object returned E_NOINTERFACE.
A class object in OLE is an intermediate object that supports an interface
that permits operations common to a group of objects. The objects in this group
are instances derived from the same object definition represented by a single
CLSID. Usually, the interface on a class object is IClassFactory
, through which you can create object instances of a given definition (class).
A call to CoGetClassObject
creates, initializes, and gives the caller access (through an interface
specified with the riid
parameter) to the class object. The class object is the one associated with
the CLSID that you specify in the rclsid
parameter. Details of how code and data are located and associated are
transparent to the caller, as is the dynamic loading of associated code not already
loaded. There are two places to find a CLSID for a given object definition:
- The registry holds an association between CLSIDs and file suffixes, and
between CLSIDs and file signatures for determining the class of an object.
- When an object is saved to persistent storage, its CLSID is stored with its
To create and initialize embedded or linked OLE document objects, it is not
necessary to call CoGetClassObject
directly. Instead, call one of the OleCreate
helper functions. These functions encapsulate the entire object instantiation
and initialization process, and call, among other functions, CoGetClassObject
parameter specifies the interface the client will use to communicate with the
class object. In most cases, this interface is IClassFactory
. This provides access to the IClassFactory::CreateInstance
member function, through which the caller can then create an uninitialized
object of the kind specified in its implementation. All object definitions
registered in the system with a CLSID must implement IClassFactory
In rare cases, however, you may want to specify some other interface that
defines operations common to a set of objects. For example, in the way OLE
implements monikers, the interface on the class object is IParseDisplayName
, used to transform the display name of an object into a moniker.
parameter specifies the execution context, allowing one CLSID to be
associated with different pieces of code in different execution contexts. The CLSCTX
enumeration , defined in COMPOBJ.H, specifies the available context flags. CoGetClassObject
consults (as appropriate for the context indicated) both the registration
database and the class objects that are currently registered by calling the CoRegisterClassObject
- Software for developers
Software for Android Developers
- More information resources
Unix Manual Pages
- Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database