At some point after a client starts a session with MAPI, your service provider will be started. Transport providers are started when a client makes a request for their services. Address book and message store providers are started during the client's logon process. A client calls IMAPISession::OpenAddressBook to load each of the address book providers included in the profile and IMAPISession::OpenMsgStore to load a specific message store provider. Address book providers that are part of a message service are started before any of the other providers in the service.
MAPI starts each service provider in the active profile by:
You are required to register the name of your provider DLL in the MAPISVC.INF configuration file to ensure that it appears in the profile. When your service provider is added to a profile, either individually or as part of a message service, all of the [Service Provider] sections from MAPISVC.INF that apply to your provider are copied into the profile. For more information about the structure of MAPISVC.INF, see File Format of MAPISVC.INF.
Because MAPI calls LoadLibrary either every time it uses a service provider DLL, regardless of whether it has already been loaded, or only the first time, your service provider must not make assumptions about the number of times that it will be loaded. For every call to LoadLibrary, MAPI makes a call to the Windows API function FreeLibrary when a service provider DLL is no longer needed.
MAPI calls your provider's entry point function to initiate the logon process. Entry point functions ensure that you are using a version of the service provider interface (SPI) that is compatible with the version being used by MAPI. These functions also return pointers to newly created provider objects. For information about creating an entry point function for your provider, see Implementing a Service Provider Entry Point Function.