Windows Service Client Applications

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

To enable client applications that are written as Windows services to operate with MAPI-compliant service providers, MAPI imposes several limitations and requirements.

MAPI clients have the following limitations:

  • They cannot allow a user interface.

  • They can send messages only through a tightly coupled message store and transport provider. In addition, MAPI clients can send and receive messages by using only the Microsoft Exchange Server or another server-based transport provider. Because of identity and security issues between client applications and the MAPI spooler, most transport providers are not supported in a service.

All client applications, whether they are implemented as services, must call the MAPIInitialize function to initialize the MAPI libraries. A call to the OleInitialize function is also necessary to use the OLE libraries. Both MAPIInitialize and OleInitialize make calls to the CoInitialize function to initialize the Component Object Model (COM) libraries. Clients that are services must set a special flag, MAPI_NT_SERVICE, in the ulFlags member of the MAPIINIT_0 structure that is passed to MAPIInitialize and in the ulFlags parameter that is passed to the MAPILogonEx function to inform MAPI of their special implementation.

Service clients written with the MAPI client interface have an additional requirement. They must set the MAPI_NO_MAIL flag in the call to MAPILogonEx. Other types of service clients do not have to set a flag for logon because it is automatically set by MAPI.

To handle messages in an initialization thread, a MAPI client that is implemented as a service does the following:

  1. Calls the MsgWaitForMultipleObjects function when the main thread blocks.

  2. Calls the GetMessage, TranslateMessage, and DispatchMessage sequence of Windows functions to handle the message when MsgWaitForMultipleObjects returns the sum of the value of the nCount parameter and the value of WAIT_OBJECT_0, which indicates that a message is in the queue.

See Also

Reference

MAPIInitialize

MAPIINIT_0

MAPILogonEx

Concepts

Operating Environment Issues