Principles and discussion of Windows service writing (1)

Source: Internet
Author: User
Tags exception handling

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.