Shutting Down a Service Provider

When a client calls IMAPISession::Logoff to end the session and shut down all active service providers, MAPI in turn calls:

Each of these methods have similar implementations. The main tasks that a logoff method performs are:

  1. Releasing all open objects, including subobjects and status objects.
  2. Calling the support object's IUnknown::Release method to decrement its reference count.
  3. Removing all of your provider's registered MAPIUIDs.
  4. Removing your provider's row in the status table.
  5. Performing any tasks that relate to cleaning up resources, such as:

When your logoff method returns, MAPI calls:

  1. Your logon object's IUnknown::Release method.
  2. Your provider object's Shutdown method to perform any final cleanup tasks. Depending on the type of your provider, the following method is called:
  3. 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 affect on the session. Only a message store provider can be shut down with this method; there is no explicit way for shutting 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.