previous page
next page

Just Say "No"

COM_INTERFACE_ENTRY_NOINTERFACE

Sometimes, you want to short-circuit the interface request by explicitly returning E_NOINTERFACE when a specific interface is requested. For this, ATL provides COM_INTERFACE_ENTRY_NOINTERFACE:

#define COM_INTERFACE_ENTRY_NOINTERFACE(x) \
  { &_ATL_IIDOF(x), NULL, _NoInterface },   

The _NoInterface function does pretty much what you'd expect:

static HRESULT WINAPI                                  
CComObjectRootBase::_NoInterface(void*, REFIID, void**,
  DWORD_PTR)                                           
{ return E_NOINTERFACE; }                              

This interface map macro is handy when you've got blind entries in the interface map, as in blind aggregation or chaining, and you want to remove functionality that the inner object or the base class provides. For example

class CBigNiceBeachBall :
  public CBeachBall,
  public IBigObject {
public:
BEGIN_COM_MAP(CBigNiceBeachBall)
  COM_INTERFACE_ENTRY(IBigObject)
  COM_INTERFACE_ENTRY_NOINTERFACE(ILethalObject)
  COM_INTERFACE_ENTRY_CHAIN(CBeachBall)
END_COM_MAP()
...
};


previous page
next page
Converted from CHM to HTML with chm2web Pro 2.75 (unicode)