CComObjectGlobal

template <class Base>
class CComObjectGlobal : public
Base

Parameters

Base Your class, typically derived from CComObjectRoot or CComObjectRootEx, as well as from any other interface you want to support on the object.

CComObjectGlobal manages a reference count on the module containing your Base object. CComObjectGlobal ensures your object will not be deleted as long as the module is not released. Your object will only be removed when the reference count on the entire module goes to zero.

For example, using CComObjectGlobal, a class factory can hold a common global object that is shared by all its clients.

#include <atlcom.h>

See Also CComObjectStack, CComAggObject, CComObject


CComObjectGlobal Class Members

Methods
AddRefImplements a global AddRef.
CComObjectGlobalConstructor.
QueryInterfaceImplements a global QueryInterface.
ReleaseImplements a global Release.
Data Members
m_hResFinalConstructContains the HRESULT returned during construction of the CComObjectGlobal object.

CComObjectGlobal Overview


Methods


CComObjectGlobal::AddRef

ULONG AddRef( );

Return Value

A value that may be useful for diagnostics and testing.

Remarks

Increments the reference count of the object by 1. By default, AddRef calls _Module::Lock, where _Module is the global instance of CComModule or a class derived from it.

CComObjectGlobal Overview | Class Members

See Also CComObjectGlobal::Release, CComModule::Lock


CComObjectGlobal::CComObjectGlobal

CComObjectGlobal( );

Remarks

The constructor. Calls FinalConstruct and then sets m_hResFinalConstruct to the HRESULT returned by FinalConstruct. If you have not derived your base class from CComObjectRoot, you must supply your own FinalConstruct method. The destructor calls FinalRelease.

CComObjectGlobal Overview | Class Members

See Also CComObjectRootEx::FinalConstruct


CComObjectGlobal::QueryInterface

HRESULT QueryInterface( REFIID iid, void** ppvObject ) ;

Return Value

One of the standard HRESULT values.

Parameters

iid [in] The GUID of the interface being requested.

ppvObject [out] A pointer to the interface pointer identified by iid, or NULL if the interface is not found.

Remarks

Retrieves a pointer to the requested interface pointer. QueryInterface only handles interfaces in the COM map table.

CComObjectGlobal Overview | Class Members

See Also CComObjectRootEx::InternalQueryInterface, BEGIN_COM_MAP


CComObjectGlobal::Release

ULONG Release( );

Return Value

In debug builds, Release returns a value that may be useful for diagnostics and testing. In non-debug builds, Release always returns 0.

Remarks

Decrements the reference count of the object by 1. By default, Release calls _Module::Unlock, where _Module is the global instance of CComModule or a class derived from it.

CComObjectGlobal Overview | Class Members

See Also CComObjectGlobal::AddRef, CComModule::Unlock


Data Members


CComObjectGlobal::m_hResFinalConstruct

HRESULT m_hResFinalConstruct;

Remarks

Contains the HRESULT from calling FinalConstruct during construction of the CComObjectGlobal object.

CComObjectGlobal Overview | Class Members

See Also CComObjectGlobal::CComObjectGlobal, CComObjectRootEx::FinalConstruct