|
// Advise.cpp
#include "stdafx.h"
#include "Advise.h"
/////////////////////////////////////////////////////////////////////////////////////////
// CAdvise
//
CAdvise::CAdvise(const IID& iidSinkInterface) :
m_iidSinkInterface(iidSinkInterface),
m_dwCookie(0)
{
}
CAdvise::~CAdvise()
{
UnadviseToServer();
}
HRESULT CAdvise::AdviseToServer(IUnknown* pUnk, const IUnknown* pUnkEvents)
{
CComPtr<IConnectionPointContainer> spCPCtr;
HRESULT hr = pUnk->QueryInterface( IID_IConnectionPointContainer, (void**)&spCPCtr );
if ( SUCCEEDED(hr) )
{
hr = spCPCtr->FindConnectionPoint( m_iidSinkInterface, &m_spCP );
if ( SUCCEEDED(hr) )
hr = m_spCP->Advise( (IUnknown*)pUnkEvents, &m_dwCookie );
}
return hr;
}
void CAdvise::UnadviseToServer()
{
if ( m_spCP && 0 < m_dwCookie )
m_spCP->Unadvise( m_dwCookie );
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.