Share via


CComPtr::CoCreateInstance

HRESULT CoCreateInstance( REFCLSID rclsid**, LPUNKNOWN** pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL );

HRESULT CoCreateInstance( LPCOLESTR szProgID**, LPUNKNOWN** pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL );

Return value

A standard HRESULT value. Can be one of the following values:

  • **S_OK   **An instance of the specified object class was successfully created.

  • **REGDB_E_CLASSNOTREG   **A specified class is not registered in the registration database. Also can indicate that the type of server you requested in the CLSCTX enumeration is not registered or the values for the server types in the registry are corrupt.

  • **CLASS_E_NOAGGREGATION   **This class cannot be created as part of an aggregate.

See in the Platform SDK for a description of possible return values.

Parameters

rclsid

[in] CLSID associated with the data and code that will be used to create the object.

pUnkOuter

[in] If NULL, indicates that the object is not being created as part of an aggregate. If non-NULL, a pointer to the aggregate object's IUnknown interface (the controlling IUnknown).

dwClsContext

[in] Context in which the code that manages the newly created object will run.

szProgID

[in] ProgID associated with the data and code that will be used to create the object.

Remarks

Creates an instance of an object in a type-safe manner.

CComPtr OverviewClass Members