What Is a Windows Service?

A Windows service is an application without a user interface that runs independently of any user-started applications. Typically a service starts automatically when the computer startseven if a user does not log on to the computer. Think of them as background processes that keep things humming smoothly.

There are two ways to see the services that are running on your own machine. The first is under Computer Management. Right-click the My Computer icon on your desktop and choose Manage, and then expand Services and Applications. Click the Services node and you'll see the services running on your machine, as in Figure 12.1.

Figure 12.1. The services running on your computer are listed under the Services node in Computer Management.


As a developer, you'll like the convenience of using the Server Explorer in Visual Studio .NET to view and control your services. If it's not already open, open it by choosing View, Server Explorer. Expand the Servers node, and then your own machine, and then Services. As in Figure 12.2, you'll see the same list of services as you would see under Computer Management, without having to bring up a separate tool.

Figure 12.2. You can see and control services from within Visual Studio.


Many services are referred to as servers. HTTP or Web servers, mail servers, and ftp servers all run as services on a Windows machine, as does the print server, any fax software you have installed, and similar applications. They wait in the background for requests or events to occur, and then they handle those requests or events in some way.

Another important category of services provides maintenance duties for another application. Consider an application that displays information, such as internal company announcements. Each piece of information has an expiry date, and after this date it is deleted. The job of deleting expired information is handled by a service that runs in the middle of the night, looks through all the information in the system, and deletes any with expiry dates before the current date. This ensures that expired information is always deleted, and doesn't impose any performance delays on the application that displays information to the user. This architectural choice is an excellent one for applications used by many users.


So many programmers I talk to don't even realize the Server Explorer exists. It's a tremendous time saver, giving you access to all your services, SQL databases, performance counters, and event logs. In Visual Studio 6 and earlier, I would often have three or four other applications open, and would switch back and forth between them as I developed and debugged my applications. Now it's " one-stop shopping" with the Server Explorer. If you haven't used it, building this chapter's sample application should give you plenty of opportunities. I strongly encourage you to try it out.

Microsoft Visual C++. NET 2003 Kick Start
Microsoft Visual C++ .NET 2003 Kick Start
ISBN: 0672326000
EAN: 2147483647
Year: 2002
Pages: 141
Authors: Kate Gregory

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