Introduction
You often need programs that run continuously in the background. For example, an email server is expected to listen continuously on a network port for incoming email messages, a print spooler is expected to listen continuously to print requests, and so on.
Most operating systems provide a way to create such long-running background tasks. In fact, operating systems themselves run a variety of background processes critical for their functionality. In Unix, the background tasks are called daemons; in Windows NT, the background tasks are called NT services; whereas in Window 2000,Windows XP, and Windows Server 2003 operating systems, the background tasks are called Windows services.
Although Windows services are created as normal executable files, they have at least two distinct characteristics:
Windows services must conform to the interface of the Service Control Manager (SCM). The SCM is a part of the Windows operating system responsible for managing Windows services. Windows services must be installed in the Windows service database before they can be used.
In this chapter, you'll use the .NET Framework class libraries to develop the following skills that will help you to create your own Windows services:
Creating a Windows service that conforms to the interface of the Windows Service Control Manager (SCM). Creating an installer class that is capable of installing a Windows service to the Windows service database. Using the Installer tool (installutil.exe) to install and uninstall a Windows service in the Windows service database. Connecting to a Windows service and issuing messages such as start, stop, pause, and continue. Querying a Windows service to retrieve its status.
|