CComObjectStack Class

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at CComObjectStack Class.

This class creates a temporary COM object and provides it with a skeletal implementation of IUnknown.

template <class  Base>  
class CComObjectStack
 : public Base

Parameters

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

Public Constructors

NameDescription
CComObjectStack::CComObjectStackThe constructor.
CComObjectStack::~CComObjectStackThe destructor.

Public Methods

NameDescription
CComObjectStack::AddRefReturns zero. In debug mode, calls _ASSERTE.
CComObjectStack::QueryInterfaceReturns E_NOINTERFACE. In debug mode, calls _ASSERTE.
CComObjectStack::ReleaseReturns zero. In debug mode, calls _ASSERTE. ~

Public Data Members

NameDescription
CComObjectStack::m_hResFinalConstructContains the HRESULT returned during construction of the CComObjectStack object.

CComObjectStack is used to create a temporary COM object and provide the object a skeletal implementation of IUnknown. Typically, the object is used as a local variable within one function (that is, pushed onto the stack). Since the object is destroyed when the function finishes, reference counting is not performed to increase efficiency.

The following example shows how to create a COM object used inside a function:

void MyFunc()
{
   CComObjectStack<CMyClass2> Tempobj;
   //...
}

The temporary object Tempobj is pushed onto the stack and automatically disappears when the function finishes.

Base

CComObjectStack

Header: atlcom.h

Returns zero.

STDMETHOD_(ULONG, AddRef)();

Return Value

Returns zero.

Remarks

In debug mode, calls _ASSERTE.

The constructor.

CComObjectStack(void* = NULL);

Remarks

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.

The destructor.

CComObjectStack();

Remarks

Frees all allocated resources and calls FinalRelease.

Contains the HRESULT returned from calling FinalConstruct during construction of the CComObjectStack object.

HRESULT m_hResFinalConstruct;

Returns E_NOINTERFACE.

HRESULT QueryInterface(REFIID, void**);

Return Value

Returns E_NOINTERFACE.

Remarks

In debug mode, calls _ASSERTE.

Returns zero.

STDMETHOD_(ULONG, Release)();

Return Value

Returns zero.

Remarks

In debug mode, calls _ASSERTE.

CComAggObject Class
CComObject Class
CComObjectGlobal Class
Class Overview

Show: