Shutting Down a Service Provider
Applies to: Office 2010 | Outlook 2010 | Visual Studio
When a client calls the IMAPISession::Logoff method to end the session and shut down all active service providers, MAPI in turn calls the following methods:
IABLogon::Logoff for address book providers.
IMSLogon::Logoff for message store providers.
IXPLogon::TransportLogoff for transport providers.
These methods have similar implementations. The main tasks that a logoff method performs are as follows:
Releasing all open objects, including subobjects and status objects.
Calling the support object's IUnknown::Release method to decrement its reference count.
Removing all of your provider's registered MAPIUID structures.
Removing your provider's row in the status table.
Performing any tasks that relate to cleaning up resources, such as the following:
Terminating a connection with a remote server.
Decrementing the reference count on the logon object.
Removing the logon object from the list of logon objects that your provider stores.
In debug mode, issuing traces to locate objects that have leaked memory.
When your logoff method returns, MAPI calls the following:
Your logon object's IUnknown::Release method.
Your provider object's Shutdown method to perform any final cleanup tasks. Depending on the type of your provider, one of the following methods is called:
IABProvider::Shutdown for address book providers
IMSProvider::Shutdown for message store providers
IXPProvider::Shutdown for transport providers
Your provider object's IUnknown::Release method.
If your provider is a message store, a client call to IMsgStore::StoreLogoff will also initiate the shutdown process. StoreLogoff shuts down one particular message store provider and has no effect on the session. Only a message store provider can be shut down with this method; there is no explicit way to shut down a particular address book or transport provider. For information about how to respond to a StoreLogoff call, see Shutting Down a Message Store Provider.
Your provider's DLL will be unloaded when MAPI calls the Win32 API function FreeLibrary, a call that is made after the last active client has called MAPIUninitialize. By this time, your service provider will have finished shutting down.