Chapter 36. Windows Services

Windows Services are programs that can be started automatically at boot-time without the need of anyone logging on to the machine. After reading this chapter, you can modify the server processes from Chapter 29, ".NET Remoting," and Chapter 35, "Accessing the Internet," to be started automatically.

In the following pages, you learn:

  • The architecture of Windows Services; the functionality of a service program, service control program, and service configuration program.

  • How to implement a Windows Service with the classes found in the System.ServiceProcess namespace.

  • Installation programs to configure the Windows Service in the registry.

  • How to write a program to control the Windows Service using the ServiceController class.

  • How to implement event handling.

  • How to add event logging to other application types.

  • How to implement performance monitoring for a Windows Service.

The first section explains the function of a Windows Service. (You can download the code for this chapter from the Wrox Web site at www.wrox.com.)

What Is a Windows Service?

Windows Services are applications that can be automatically started when the operating system boots. They can run without having an interactive user logged on to the system. You can configure a Windows Service to be run from a specially configured user account; or from the system user account—a user account that has even more privileges than that of the system administrator.

Note

Windows Services don't run on Windows 95, 98, or ...

Get Professional C# 2005 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.