HOWTO: Override IUnknown Methods in an ATL Server
ID: Q218982
|
The information in this article applies to:
-
The Microsoft Active Template Library (ATL) 3.0, included with:
-
Microsoft Visual C++, 32-bit Editions, version 6.0
SUMMARY
This article shows how to override the IUnknown methods (AddRef, Release and QueryInterface) in an ATL server.
MORE INFORMATION
When the client calls AddRef, Release or QueryInterface, the following functions that can be overridden are called:
CComObjectRootEx<>::InternalAddRef()
CComObjectRootEx<>::InternalRelease()
CComObjectRootBase::InternalQueryInterface()
To override these functions, copy and paste the following functions in your ATL class:
ULONG InternalAddRef()
{
// do something
return CComObjectRootEx<_ThreadModel>::InternalAddRef();
}
ULONG InternalRelease()
{
// do something
return CComObjectRootEx<_ThreadModel>::InternalRelease();
}
HRESULT WINAPI InternalQueryInterface(void* pThis, const _ATL_INTMAP_ENTRY* pEntries, REFIID iid, void** ppvObject)
{
// do something
return CComObjectRootBase::InternalQueryInterface(pThis, pEntries, iid, ppvObject);
}
Additional query words:
Keywords : kbCOMt kbVC600 kbATL300 kbGrpMFCATL kbArchitecture
Version : WINDOWS:3.0
Platform : WINDOWS
Issue type : kbhowto