Architecture of Windows Services

   


As shown in Figure 6.1, there are five main components in the Windows services architecture:

  • Windows Services Database

  • Service Control Manager

  • Windows Service Installer

  • Windows Services in Execution

  • Windows Service Controller

Figure 6.1. The Service Control Manager provides a unified way to control, configure, and access Windows services.

I'll discuss each of these components in the following sections.

Windows Service Database

The Windows service database stores information about all the installed services. This database is a part of the Windows registry and is stored in the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services key. The Windows service database typically contains the following information for each Windows service:

  • Path to the executable file

  • Security settings

  • Startup parameters

Even though you can directly manipulate the Windows service database by modifying the Windows Registry with the Regedit command or through a program, this isn't a good idea. To ensure the integrity of the database, you should always manipulate the Windows service database through the interfaces provided by the SCM.

Service Control Manager (SCM)

SCM is a Windows component that maintains the Windows service database and provides a unified way to control, configure, and access these services. The SCM performs the following tasks :

  • Accepts requests to install and uninstall Windows services from the Windows service database.

  • Starts Windows services either on system startup or on demand.

  • Enumerates installed Windows services.

  • Maintains status information for running Windows services.

  • Transmits control messages (such as Start, Stop, Pause, and Continue) to running Windows services.

  • Locks and unlocks the Windows service database.

NOTE

Microsoft Management Console ( MMC ) MMC is an integrated administration environment for administrating Windows components and installed applications. By itself, MMC can't do much. However, applications and Windows components provide snap-ins that hook into the MMC and extend its explorer-like user interface with menus , toolbars , property sheets, and wizards to perform specific administration tasks. Most MMC snap-ins have a similar look and feel. This helps administrators to leverage their existing knowledge and quickly learn how to administer new applications.


Windows provides a generic interface to work with the SCM through the Services and Computer Management MMC (Microsoft Management Console) snap-ins. These MMC snap-ins can be accessed through the administrative tool section of the Windows Control Panel. Some applications, such as IIS and SQL Server, provide their own MMC snap-ins to control and configure their services.

NOTE

Windows Services on Remote Machines The SCM is started as a remote procedure call (RPC) server. This enables the Windows service control programs to manipulate services on remote machines.


Windows Service Installer

A Windows service installer uses the SCM to install, uninstall, and repair a Windows service. The install, uninstall, and repair actions respectively create, delete, and update a Windows service record in the Windows service database.

While installing a service, the Windows service installer also stores information about how the service will be started. This information includes

  • A name that uniquely identifies the service in the Windows service database

  • The account name and password under whose identity the service runs

  • How the Windows service process is created (an independent process or a shared process)

  • How the service is started (automatically when Windows starts, manual start, disabled)

Windows Services in Execution

Just installing a service in the Windows service database is not sufficient to use the functionality of a service. By default, a Windows service must be explicitly started. However, it is also possible to set up a service in such a way that the service is started automatically with Windows.

When the SCM starts a service, it attempts to create a Windows process for that service based on the information stored in the Windows service database. The SCM also sends a Start message to the service; this message invokes an associated handler in the service (if any) that specifies the processing to be done at startup.

Once a Windows service is started, it continues to run until it receives a pause or stop message. When a Windows service is paused , the process for the Windows service continues to exist, but the service does not receive any request from client programs. On the other hand, when a Windows service is stopped , its process is terminated and the memory is reclaimed.

Windows Service Controller Program

The Windows service controller program uses the SCM to perform the following tasks:

  • Start a Windows service.

  • Stop a Windows service.

  • Pause a Windows service.

  • Resume the execution of a paused Windows service.

  • Query the Windows service database to retrieve the status for a Windows service.

  • Install a new Windows service in the Windows service database.

  • Uninstall an installed Windows service from the Windows service database.

  • Modify the configuration information for a Windows service.

You might question the need of the Windows service controller program when the Services MMC snap-in is already available to perform various control and administrative tasks for a Windows service. Although the Services MMC snap-in provides generic control and configuration options for Windows services, it cannot take care of the individual configuration requirement and customized user interface for each Windows service. For example, IIS provides an Internet Information Services snap-in in the MMC to administer the World Wide Web Publishing, FTP Publishing, Network News Transfer Protocol (NNTP), and Simple Mail Transfer Protocol (SMTP) services.

REVIEW BREAK

  • Windows services are applications that conform to the interface of the Windows Service Control Manager (SCM). ACM is the part of Windows responsible for managing Windows services.

  • Windows services are quite distinct from regular Windows applications. One of most apparent distinctions is that Windows applications usually lack GUI. In addition, Windows services typically run in the background and run in their own process with a specific user identity.

  • Windows services must be installed in the Windows services database before they can be used. The Windows services database is a part of the Windows Registry. It is recommended, however, that you should not directly modify the database but rather modify the database through the SCM.


   
Top


MCAD. MCSD Training Guide (Exam 70-310. Developing XML Web Services and Server Components with Visual Basic. NET and the. NET Framework)
MCAD/MCSD Training Guide (70-310): Developing XML Web Services and Server Components with Visual Basic(R) .NET and the .NET Framework
ISBN: 0789728206
EAN: 2147483647
Year: 2002
Pages: 166

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net