Platform SDK: Exchange Server

Installing the Gateway as a Service

If your gateway runs as a service of Windows NT Server, you must install it in the Windows NT service control manager (SCM). Making your gateway a service of Windows NT Server enables it to start up automatically when the computer is turned on and to run in its own security context. Users also gain the ability to control the gateway through the operating system, instead of requiring a custom user interface.

To register a gateway as a service of Windows NT Server

  1. Connect to the SCM by calling the Win32 OpenSCManager function.
  2. Create the service by calling the Win32 CreateService function and passing information such as the service name and type, and the ways the service should be switched to and started.
  3. In the local Windows NT Registry, open the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services key. Do this by calling the Win32 RegOpenKeyEx function.
  4. Under this key, create other necessary keys for the service, such as the Object key, the Parameters key, and the Diagnostics key. Registry keys are created by calling the Win32 RegCreateKeyEx function.
  5. Write the configuration information that your application needs into these Registry keys.

For an example of this procedure, see the HrInstallService function in \SAMPLES\DbMsg\EXCHANGE\LIBSRC\EXCHINST.C. See Installing Event Logging for specifics on creating the Diagnostics key.