AtlUnadvise
結束藉由 AtlAdvise已建立的連接。
重要事項 |
---|
這個函式不能用於 Windows 執行階段執行的應用程式。 |
HRESULT AtlUnadvise(
IUnknown* pUnkCP,
const IID& iid,
DWORD dw
);
參數
pUnkCP
[in] 物件的指標 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