Chapter 15. Implementing Windows Services

I l @ ve RuBoard

A Windows service is a process that executes in the background, frequently implementing an operating system task. Services are a fundamental part of the Microsoft Windows operating system and are often used to provide protected access to sensitive resources. One example is the Event Log service, which writes records to the Windows event logs on behalf of applications. Another example is the World Wide Web Publishing Service, which controls Microsoft Internet Information Services (IIS) and allows your computer to act as a Web server. If you've used other operating systems such as UNIX, you might be familiar with daemon processes, which fulfill a similar role. (Do not confuse daemon processes with Java daemon threads, because they belong to an ordinary user process and are not started by the operating system.)

You can configure a Windows service to start automatically when the operating system boots. The background nature of a Windows service means that its options for input and output are very limited. For example, a Windows service should not attempt to write messages to the console or display message boxes, because there's no guarantee that a user will be logged in to acknowledge them. Instead, Windows services receive input from other applications through a set of APIs defined as part of the Windows operating system. Similarly, error information and other significant output is typically recorded in the Windows event logs.

You can create your own services using a variety of tools and techniques, ranging from the low-level Windows APIs available with the Platform SDK to simply configuring a COM+ application to execute as a service. Using the Windows APIs gives you a lot more control than the COM+ application option, but it requires that you write a lot more code. The .NET Framework Class Library provides a middle ground, allowing you to be in command of the operations performed by a Windows service but abstracting out many of the low-level details. The System.ServiceProcess namespace provides managed wrappers for the Windows service APIs, and Microsoft Visual Studio .NET provides the Windows Service template to use in creating your own service applications.

In this chapter, we'll examine how to interact with existing Windows services from Microsoft Visual J#. Then we'll look at how to create a new Windows service and examine such topics as service installation and service security with J#.

I l @ ve RuBoard


Microsoft Visual J# .NET (Core Reference)
Microsoft Visual J# .NET (Core Reference) (Pro-Developer)
ISBN: 0735615500
EAN: 2147483647
Year: 2002
Pages: 128

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