Platform SDK: MAPI

Shutting Down a Message Store Provider

If your provider is a message store provider, it can be shut down in two ways:

Your implementation of IMsgStore::StoreLogoff should begin by calling IMAPISupport::StoreLogoffTransports to inform MAPI that it is being shut down, indicating that any related transport providers should be logged off. When IMsgStore::StoreLogoff returns, its caller invokes your message store's IUnknown::Release method. Implement this Release method by calling the support object's IUnknown::Release method.

MAPI performs the following tasks in its implementation of IUnknown::Release for message stores:

  1. Removes all of the MAPIUIDs registered by the message store provider.
  2. Removes the message store provider's row from the status table.
  3. Calls IMSLogon::Logoff to release all open objects, subobjects, and status objects.
  4. Calls IMSLogon::Release to release the message store provider's logon object.

Some clients might omit the call to IMsgStore::StoreLogoff, initiating the shutdown of your message store provider with the call to the message store's IUnknown::Release method. A shutdown under these circumstances without the call to StoreLogoff is less orderly and controlled. Write your message store's Release method to handle this possibility and keep track of whether or not a call to IMAPISupport::StoreLogoffTransports has occurred. StoreLogoffTransports must be called once during the shutdown process. If you detect in your Release method that StoreLogoffTransports has not yet been called, invoke it with the LOGOFF_ABORT flag.