There is a class of applications that can be used by a variety of users, both local and remote, and have the ability to manage at a user's authorization level, and whether the user is physically connected to the computer running the application, this is called a service.
(i) basic knowledge of services
Question 1. What is a service? What is the characteristic of it?
In nt/2000, services are a class of programs that are favored by the operating system. A service is first a WIN32 executable program that requires familiarity with dynamic connection libraries (Dlls), structural exception handling, memory-mapped files, virtual memory, device I/O, threads and their synchronization if you want to write a full-featured and powerful service. Unicode and other application interfaces provided by the WINAPI function. Of course, this article is only to build a can install, run, start, stop the service without any other functions, so without this knowledge can continue to look at, I will understand this article in the process of the knowledge needed to explain one by one.
The second need to know is that a service never requires a user interface. Most of the services will run on powerful servers that are locked in some dark, winter-warm, summer-cool Little house, even with a user interface that no one can see. If the service provides any user interface such as a message box, the likelihood that the user will miss these messages is very high, so the service program is usually written in the form of a console program, and the entry function is main () instead of WinMain ().
There may be some doubt: how to set up and manage a service without the user interface? How to start and stop it? How does a service issue a warning or error message, and how do you report statistical data about its execution? The answer to these questions is that services can be managed remotely, and Windows nt/2000 provides a number of management tools that allow the services on a particular machine to be managed through other computers on the network. For example, in Windows 2000, "Console" program (mmc.exe), use it to add "snap-in" can manage the service on this machine or other machine.