Platform SDK: MAPI

HPProviderInit

The HPProviderInit function initializes a messaging hook provider for operation.

Quick Info

Header file: MAPIHOOK.H
Implemented by: Messaging hook providers
Called by: MAPI

HRESULT HPProviderInit(
  LPMAPISESSION lpSession,         
  HINSTANCE hInstance,             
  LPALLOCATEBUFFER lpAllocateBuffer,   
  LPALLOCATEMORE lpAllocateMore,   
  LPFREEBUFFER lpFreeBuffer,       
  LPMAPIUID lpSectionUID,          
  ULONG ulFlags,                   
  LPSPOOLERHOOK FAR * lppSpoolerHook  
);
 

Parameters

lpSession
[in] Pointer to the object representing the MAPI spooler session. Because the messaging hook provider runs in the spooler session, all its components must be trusted code, that is, thoroughly debugged code that does not fail or compromise the spooler's operation. The messaging hook provider should call the IUnknown::AddRef method on the session object.
hInstance
[in] The instance of the messaging hook provider's dynamic-link library (DLL) that MAPI used when it linked.
lpAllocateBuffer
[in] Pointer to the MAPIAllocateBuffer function, to be used where required by MAPI to allocate memory.
lpAllocateMore
[in] Pointer to the MAPIAllocateMore function, to be used where required by MAPI to allocate additional memory.
lpFreeBuffer
[in] Pointer to the MAPIFreeBuffer function, to be used where required by MAPI to free memory.
lpSectionUID
[in] Pointer to the MAPIUID of the messaging hook provider's profile section. HPProviderInit can open this identifier using a session-level call to the IMAPISupport::OpenProfileSection method. However, because MAPI and the MAPI spooler control some properties in the session, the provider should use the range of provider-specific property identifiers for storage and retrieval of profile section properties.
ulFlags
[in] Bitmask of flags used to control whether the messaging hook provider is called for incoming or outgoing messages. The following flags can be set:
HOOK_INBOUND
The messaging hook provider processes messages inbound to the MAPI spooler.
HOOK_OUTBOUND
The messaging hook provider processes messages outbound from the MAPI spooler.
MAPI_NT_SERVICE
The provider is being loaded in the context of a Windows NT service, a special type of process without access to any user interface.
lppSpoolerHook
[out] Pointer to a pointer to the initialized messaging hook provider object.

Return Values

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

Remarks

MAPI calls the entry point function HPProviderInit to initialize a messaging hook provider following a client logon. HPProviderInit is called once for each messaging hook provider specified in the client's profile.

Notes to Implementers

A messaging hook provider must implement HPProviderInit as an entry point function in the provider's DLL. The implementation must be based on the HPPROVIDERINIT function prototype, also specified in MAPIHOOK.H. MAPI defines HPPROVIDERINIT to use the standard MAPI initialization call type, STDMAPIINITCALLTYPE, which causes HPProviderInit 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, HPProviderInit must return a different provider object in lppSpoolerHook for each initialization, even for multiple initializations in the same process.

The messaging hook 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 needs to use mutex objects or critical sections, it should set them up during initialization using HPProviderInit. A mutex object should be owned by the message-hook provider object created by this function.

For more information on writing HPProviderInit, see Implementing HPProviderInit for Hook Providers. For more information on entry point functions, see Implementing a Service Provider Entry Point Function.

See Also

Provider Initialization Functions, ABProviderInit, IMAPISession : IUnknown, MSProviderInit, XPProviderInit