The IABLogon::Advise method registers to receive notification of specified events affecting a container, messaging user, or distribution list.
See IABLogon : IUnknown.
HRESULT Advise(
ULONG cbEntryID,
LPENTRYID lpEntryID,
ULONG ulEventMask,
LPMAPIADVISESINK lpAdviseSink,
ULONG FAR * lpulConnection
);
The following table lists the valid values for the ulEventMask parameter and the structures associated with each value.
Notification event type | Corresponding NOTIFICATION structure |
---|---|
|
ERROR_NOTIFICATION |
|
OBJECT_NOTIFICATION |
|
OBJECT_NOTIFICATION |
|
OBJECT_NOTIFICATION |
|
OBJECT_NOTIFICATION |
|
OBJECT_NOTIFICATION |
Address book providers implement the IABLogon::Advise method to register the caller to be notified when a change occurs to an object in one of their containers. Callers can register for notifications on messaging users, distribution lists, or entire containers.
Clients typically call IAddrBook::Advise to register for address book notifications. MAPI then calls the IABLogon::Advise method of the address book provider that is responsible for the object represented by the entry identifier in lpEntryID.
When a change occurs to the indicated object of the type represented in ulEventMask, a call is made to the OnNotify method of the advise sink pointed to by lpAdviseSink. Data passed in the notification structure to the OnNotify routine describes the event.
You can support notification with or without help from MAPI. MAPI has three support object methods for helping service providers implement notification:
If you elect to use the MAPI support methods, call Subscribe when your Advise method is called and release the lpAdviseSink pointer.
If you elect to support notification yourself, call the IUnknown::AddRef method of the advise sink represented by the lpAdviseSink parameter to keep a copy of this pointer. Maintain this copy until your IABLogon::Unadvise method is called to cancel the registration.
Regardless of how you support notification, assign a nonzero connection number to the notification registration and return it in the lpulConnection parameter. Do not release this connection number until Unadvise has been called.
The advise sink pointer that you pass in the lpAdviseSink parameter to Advise can point to an object that you have created or that MAPI has created through the HrThisThreadAdviseSink function. You might want to use HrThisThreadAdviseSink if you support multiple threads of execution and want to ensure that subsequent calls to your OnNotify method occur at an appropriate time on an appropriate thread.
Be prepared for your advise sink object to be released any time after your call to Advise and before your call to Unadvise. MAPI recommends that you release your advise sink object after Advise returns, unless you have a specific long-term use for it.
For more information on the notification process, see Event Notification in MAPI. For information about using the IMAPISupport methods to support notification, see Supporting Event Notification. For more information about multithreading and MAPI, see Threading in MAPI.
HrThisThreadAdviseSink, IABLogon::Unadvise, IMAPIAdviseSink::OnNotify, NOTIFICATION