Freigeben über


AtlUnadvise

Terminates the connection established through AtlAdvise.

HRESULT AtlUnadvise(
   IUnknown* pUnkCP,
   const IID& iid,
   DWORD dw 
);

Parameters

  • pUnkCP
    [in] A pointer to the IUnknown of the object that the client is connected with.

  • iid
    [in] The GUID of the connection point. Typically, this is the same as the outgoing interface managed by the connection point.

  • dw
    [in] The cookie that uniquely identifies the connection.

Return Value

A standard HRESULT value.

Example

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));

Requirements

Header: atlbase.h

See Also

Concepts

Connection Point Global Functions