Click to Rate and Give Feedback
MSDN
MSDN Library
COM
COM Fundamentals
Reference
Interfaces
IConnectionPoint
 IConnectionPoint::Advise
COM
IConnectionPoint::Advise

Establishes a connection between the connection point object and the client's sink.

HRESULT Advise( 
  IUnknown * pUnk,
  DWORD * pdwCookie
);
pUnk

[in] Pointer to the IUnknown interface on the client's advise sink. The client's sink receives outgoing calls from the connection point.

pdwCookie

[out] Pointer to a returned token that uniquely identifies this connection. The caller uses this token later to delete the connection by passing it to the IConnectionPoint::Unadvise method. If the connection was not successfully established, this value is zero.

This method supports the standard return values E_OUTOFMEMORY and E_UNEXPECTED, as well as the following:

S_OK

The connection has been established and *pdwCookie has the connection token.

E_POINTER

The value in pUnk or pdwCookie is not valid. For example, either pointer may be NULL.

CONNECT_E_ADVISELIMIT

The connection point has already reached its limit of connections and cannot accept any more.

CONNECT_E_CANNOTCONNECT

The sink does not support the interface required by this connection point.

Advise establishes a connection between the connection point and the caller's sink identified with pUnk.

The connection point must call pUnk->QueryInterface(iid, ...) to obtain the correct outgoing interface pointer to call when events occur, where iid is the IID for the outgoing interface managed by the connection point. When iid is passed to the IConnectionPointContainer::FindConnectionPoint method, an interface pointer to this same connection point is returned.

Notes to Implementers

The connection point must query the pUnk pointer for the correct outgoing interface. If this query fails, this method must return CONNECT_E_CANNOTCONNECT.

The pdwCookie value must be unique for each connection to any given instance of a connection point.

For an explanation of the requirement values, see Requirements (COM).

Windows NT/2000/XP: Requires Windows NT 4.0 or later.

Windows 95/98: Requires Windows 95 or later.

Header: Declared in ocidl.h.

Send comments about this topic to Microsoft.
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker