Shutting Down a Message Store Provider
Applies to: Outlook 2013 | Outlook 2016
If your provider is a message store provider, it can be shut down in one of the following ways:
When a client or the MAPI spooler calls IMsgStore::StoreLogoff. Shutting down a message store provider with StoreLogoff causes the shutdown to occur in an orderly and controlled manner.
When a client calls IMAPISession::Logoff.
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:
Removes all of the MAPIUID structures registered by the message store provider.
Removes the message store provider's row from the status table.
Calls IMSLogon::Logoff to release all open objects, subobjects, and status objects.
Calls IUnknown::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.