AfxConnectionAdvise
呼叫此函式所指定的來源之間建立連線pUnkSrc,並接收,所指定的pUnkSink。
BOOL AFXAPI AfxConnectionAdvise(
LPUNKNOWN pUnkSrc,
REFIID iid,
LPUNKNOWN pUnkSink,
BOOL bRefCount,
DWORD FAR* pdwCookie
);
參數
pUnkSrc
呼叫此介面的物件變數的指標。pUnkSink
若要實作之介面的物件變數的指標。iid
連線的介面 ID。bRefCount
本屬性為 TRUE 指示建立連線應會造成之參考次數的pUnkSink被遞增。錯誤指示應該不會遞增參考次數。pdwCookie
變數的指標, DWORD連線識別元則會傳回位置。這個值應該傳遞做為dwCookie參數,以AfxConnectionUnadvise時中斷連線。
傳回值
如果已建立連線 ; 非零值 否則 0。
範例
//CMySink is a CCmdTarget-derived class supporting automation.
//Instantiate the sink class.
CMySink mysink;
//Get a pointer to sink's IUnknown, no AddRef done.
IID iid = IID_IUnknown;
IUnknown* pUnkSink = mysink.GetInterface(&iid);
//Establish a connection between source and sink.
//pUnkSrc is IUnknown of server obtained by CoCreateInstance().
//dwCookie is a cookie identifying the connection, and is needed
//to terminate this connection.
AfxConnectionAdvise(pUnkSrc, IID_ISampleSink, pUnkSink, FALSE, &dwCookie);
需求
標頭: afxctl.h