Last modified: January 16, 2009

Applies to: Office 2010 | Outlook 2010 | Visual Studio

Initializes a message store provider for operation.

Header file:


Implemented by:

Message store providers

Called by:


HRESULT MSProviderInit(
  HINSTANCE hInstance,
  LPMALLOC lpMalloc,
  LPALLOCATEBUFFER lpAllocateBuffer,
  LPALLOCATEMORE lpAllocateMore,
  LPFREEBUFFER lpFreeBuffer,
  ULONG ulFlags,
  ULONG FAR * lpulProviderVer,


[in] The instance of the message store provider's dynamic-link library (DLL) that MAPI used when it linked.


[in] Pointer to a memory allocator object exposing the OLE IMalloc interface. The message store provider may need to use this allocation method when working with certain interfaces such as IStream.


[in] Pointer to the MAPIAllocateBuffer function, to be used to allocate memory.


[in] Pointer to the MAPIAllocateMore function, to be used to allocate additional memory.


[in] Pointer to the MAPIFreeBuffer function, to be used to free memory.


[in] Bitmask of flags. The following flag can be set:


The provider is being loaded in the context of a Windows service, a special type of process without access to any user interface.


[in] Version number of the service provider interface (SPI) that MAPI uses. For the current version number, see the Mapispi.h header file.


[out] Pointer to the version number of the SPI that this message store provider uses.


[out] Pointer to a pointer to the initialized message store provider object.


The call succeeded and has returned the expected value or values.


The SPI version being used by MAPI is not compatible with the SPI being used by this provider.

MAPI calls the entry point function MSProviderInit to initialize a message store provider following a client logon.

A message store provider must implement MSProviderInit as an entry point function in the provider's DLL. The implementation must be based on the MSPROVIDERINIT function prototype, also specified in MAPISPI.H. MAPI defines MSPROVIDERINIT to use the standard MAPI initialization call type, STDMAPIINITCALLTYPE, which causes MSProviderInit to follow the CDECL calling convention. An advantage of CDECL is that calls can be attempted even if the number of calling parameters does not match the number of defined parameters.

A provider can be initialized multiple times, as a result of appearing in several profiles in simultaneous use or of appearing more than once in the same profile. Because the provider object contains context, MSProviderInit must return a different provider object in lppMSProvider for each initialization, even for multiple initializations in the same process.

The provider DLL should not be linked with Mapix.dll. Instead, it should use these pointers for memory allocation or deallocation.

The message store provider should use the functions pointed to by lpAllocateBuffer, lpAllocateMore, and lpFreeBuffer for most memory allocation and deallocation. In particular, the provider must use these functions to allocate memory for use by client applications when calling object interfaces such as IMAPIProp::GetProps and IMAPITable::QueryRows. If the provider also expects to use the OLE memory allocator, it should call the IUnknown::AddRef method of the allocator object pointed to by the lpMalloc parameter.

For more information about writing MSProviderInit, see Loading Message Store Providers. For more information about entry point functions, see Implementing a Service Provider Entry Point Function.