다음을 통해 공유


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

매개 변수

  • 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.

반환 값

Nonzero if a connection was established; otherwise 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);

요구 사항

Header: afxctl.h

참고 항목

참조

AfxConnectionUnadvise

개념

MFC 매크로 및 전역