ServiceMain is the function that actually starts the service running, and its job is to notify the SCM of the progress of the service and then initiate the actual work of the service. ServiceMain does not exit until the service is terminating. The second function that must be supported is a control handler, often named HandlerEx . HandlerEx is a function that accepts commands that the service stop, restart, pause, or handle a custom request. The HandlerEx function was modified for Windows 2000 to allow context information to be passed into the handler so that a single HandlerEx can handle requests for more than a single service if multiple services are embedded in a single executable.
Servers are often in locked rooms, even closets.
The Event Logging API allows the service to record, in a standard way, the events associated with its running. Sometimes logging an event is not enough. For these cases, MAPI offers a way for a service to notify a responsible party of a problem or an event. Sometimes servers need to interact with resources that need to be protected. One way of performing this interaction is to use impersonation, where a thread in the server takes on the identity of the remote client and tries to perform the task requested.