调用此函数生成源之间的连接,指定由 pUnkSrc和接收器,指定由 pUnkSink。
BOOL AFXAPI AfxConnectionAdvise(
LPUNKNOWN pUnkSrc,
REFIID iid,
LPUNKNOWN pUnkSink,
BOOL bRefCount,
DWORD FAR* pdwCookie
);
参数
pUnkSrc
调用接口的对象的指针。pUnkSink
指向对象的指针实现接口。iid
连接的接口 ID。bRefCount
TRUE 意味着创建连接应使引用计数 pUnkSink 增加。FALSE 指示不应递增引用计数。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);
要求
Header: afxctl.h