Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
TRY
Expand Minimize

AfxConnectionAdvise

Call this function to establish a connection between a source, specified by pUnkSrc, and a sink, specified by pUnkSink.

BOOL AFXAPI AfxConnectionAdvise(
   LPUNKNOWN pUnkSrc,
   REFIID iid,
   LPUNKNOWN pUnkSink,
   BOOL bRefCount,
   DWORD FAR* pdwCookie 
);

Parameters

pUnkSrc
A pointer to the object that calls the interface.
pUnkSink
A pointer to the object that implements the interface.
iid
The interface ID of the connection.
bRefCount
TRUE indicates that creating the connection should cause the reference count of pUnkSink to be incremented. FALSE indicates that the reference count should not be incremented.
pdwCookie
A pointer to a DWORD where a connection identifier is returned. This value should be passed as the dwCookie parameter to AfxConnectionUnadvise when disconnecting the connection.

Return Value

Nonzero if a connection was established; otherwise 0.

Example

//CMySink is a CCmdTarget-derived class supporting automation.
//Instantiate the sink class and hold a pointer to it.
m_pSink = new CMySink();

//Get a pointer to sinks IUnknown, no AddRef done. CMySink implements only
//dispinterface and the IUnknown and IDispatch pointers will be same.
LPUNKNOWN pUnkSink = m_pSink->GetIDispatch(FALSE);

//Establish a connection between source and sink.
//m_pUnkSrc is IUnknown of server obtained by CoCreateInstance().
//m_dwCookie is a cookie identifying the connection, and is needed
//to terminate this connection.
AfxConnectionAdvise(m_pUnkSrc, IID_MYEVENT, pUnkSink, FALSE,
   &m_dwCookie);

See Also

MFC Macros and Globals | AfxConnectionUnadvise

Show:
© 2015 Microsoft