AtlUnadvise
停止通过 AtlAdvise生成的连接。
重要
此功能无法在 Windows 运行时执行的应用程序。
HRESULT AtlUnadvise(
IUnknown* pUnkCP,
const IID& iid,
DWORD dw
);
参数
pUnkCP
[out]一个指向对象的 IUnknown 的指针客户端与通信。iid
[in] 的GUID连接点。 通常,这是作为输出接口由管理连接点的相同。dw
[in]唯一标识连接的cookie。
返回值
标准HRESULT值。
示例
LPUNKNOWN m_pSourceUnk;
LPUNKNOWN m_pSinkUnk;
DWORD m_dwCustCookie;
// create source object
HRESULT hr = CoCreateInstance (CLSID_MyComponent, NULL, CLSCTX_ALL,
IID_IUnknown, (LPVOID*)&m_pSourceUnk);
ATLASSERT(SUCCEEDED(hr));
// Create sink object. CMySink is a CComObjectRootEx-derived class
// that implements the event interface methods.
CComObject<CMySink>* pSinkClass;
CComObject<CMySink>::CreateInstance(&pSinkClass);
hr = pSinkClass->QueryInterface (IID_IUnknown, (LPVOID*)&m_pSinkUnk);
ATLASSERT(SUCCEEDED(hr));
hr = AtlAdvise (m_pSourceUnk, m_pSinkUnk, __uuidof(_IMyComponentEvents), &m_dwCustCookie);
ATLASSERT(SUCCEEDED(hr));
// do something
CComBSTR bstrMsg(L"Hi there!");
((CMyComponent*)m_pSourceUnk)->Fire_ShowMyMsg(bstrMsg);
hr = AtlUnadvise (m_pSourceUnk, __uuidof(_IMyComponentEvents), m_dwCustCookie);
ATLASSERT(SUCCEEDED(hr));
要求
Header: atlbase.h