Windows NT Service Client Applications
To enable client applications that are written as Windows NT services to operate with MAPI-compliant service providers, MAPI imposes several limitations and requirements. Simple MAPI, CMC, and MAPI clients have the following limitations:
-
They cannot allow a user interface.
-
They can only send messages through a tightly coupled message store and transport provider. In addition, MAPI clients can only send and receive messages using 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 Windows NT service.
All client applications, whether or not they are implemented as Windows NT services, must call MAPIInitialize to initialize the MAPI libraries. A call to OleInitialize is also necessary to use the OLE libraries. Both MAPIInitialize and OleInitialize make calls to CoInitialize to initialize the Component Object Model (COM) libraries. Clients that are Windows NT 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 MAPILogonEx to inform MAPI of their special implementation.
Windows NT service clients written with the MAPI client interface have a few additional requirements:
-
They must set the MAPI_NO_MAIL flag in the call to MAPILogonEx. Other types of Windows NT service clients need not set a flag for logon because it is automatically set by MAPI.
-
They must add the service's account to the group of accounts called Administrators on the machine that the service is using. This is necessary for profile access. If the account does not belong to this Administrators group of accounts, the MAPIInitialize function will fail when called.
Note The requirement that the account belong to the Administrators group will be removed in a future release of Windows NT.
To handle messages in an initialization thread, a MAPI client that is implemented as a Windows NT service
-
Calls MsgWaitForMultipleObjects when the main thread blocks.
-
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, indicating that a message is in the queue.
To produce application log entries through asserts and error traces
-
Use the debug version of MAPI.
-
Add the following lines to the debug initialization file, MAPIDGB.INI:
[General]
DebugTrace=1
EventLog=1