HRESULT FinalConstruct( );
Return Value
One of the standard HRESULT values.
Remarks
Typically, override this method in the class derived from CComObjectRootEx to create any aggregated objects. For example:
class CMyAggObject : public CComObjectRootEx< ... >
{
DECLARE_GET_CONTROLLING_UNKNOWN
HRESULT FinalConstruct( )
{
return CoCreateInstance(CLSID_SomeServer,
GetControllingUnknown(), CLSCTX_ALL,
IID_ISomeServer, &m_pSomeServer);
}
...
};
If the construction fails, you can return an error. You can also use the macro DECLARE_PROTECT_FINAL_CONSTRUCT to protect your outer object from being deleted if (during creation) the internal aggregated object increments the reference count then decrements the count to 0.
By default, CComObjectRootEx::FinalConstruct simply returns S_OK.
Here is a typical way to create an aggregate:
CComObjectRootEx Overview | Class Members
See Also CComObjectRootEx::FinalRelease, DECLARE_GET_CONTROLLING_UNKNOWN