Environment: Windows 2003,VC 6.0
Absrtact: Start with a COM service program, then transform an MFC project into a service program, and finally let this program display a graphical interface at startup.
Keyword: Windows service program COM Service starts NT service and desktop interaction before booting
One, what is the Windows service program?
You can see it using the following methods.
Open the Control Panel, then the Management tool, which has a "service", double-click and open;
or by entering the command, open the Start menu, click Run, input MMC services.msc (MMC can be omitted), can also open;
We'll see a big list on the open page with names, descriptions, status, startup type, login status, and so on. The services that are already started on the system are shown as "started" in the Status column. Let's look at the properties of the service first. For example, find the name of the print spooler, and then right-click on it, select Properties, and you can see that the command line it executes is C:\WINDOWS\system32\ Spoolsv.exe, the Spoolsv.exe process exits in Task Manager after you press stop. The list we see is the focus of the service program, and each item is a service program.
These service programs, which are marked as starting from the above, are started with the system. It with some modifications to the registry:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
Items, and a program similar to a registry key, are run even if the user is not logged on to the system, or they run before the system logs on.
Second, how to establish their own service procedures?
Each service program corresponds to a subkey under the registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services. So we can increase the service program by adding a registry entry. For example, I want to add a test1 service now, the corresponding executable file is C:\test1.exe. Then I want to add the following registry key: