The establishment of service under Winnt

Source: Internet
Author: User

A very important difference between Windows NT and Windows 9x is that Windows NT offers a number of powerful service (services). These service can be started with NT start, also can let the user start through the Control Panel, also can be WIN32 application to stop. These service can be performed even without the user logging on to the system. Many FTP, WWW servers and databases exist on the NT in the form of service, thus realizing unattended. Even the latest version of the "hacker" program Back Orifice 2000 also in the form of service in NT hiding. Because of the complexity of service programming, many developers want to develop their own service but are often discouraged. In view of this, we will construct a new service from beginning to end, so that readers can easily have their own service if they add their own code to the place noted in the program. Before you write a service, let's introduce several important functions:

1. Sc_handle OpenSCManager (LPCTSTR lpmachinename,

LPCTSTR Lpdatabasename, DWORD dwdesiredaccess)

OpenSCManager function to open the service control on the specified computer

Manager database. Where the parameter lpmachinename specifies the computer name and, if it is empty, is specified as a native. LPDATABASENAME specifies that the Service Control Manager database name you want to open is null by default. dwDesiredAccess Specify the permissions for the operation, you can take one of the following values:

Sc_manager_all_access//All rights

Sc_manager_connect//Allow connection to service control MANAGER database

Sc_manager_create_service//allows creating a service object and adding it to the database

Sc_manager_enumerate_service//Allow enumeration of SERVICE in database

Sc_manager_lock//Allow lock database

Sc_manager_query_lock_status//Allow query database for blocking information

Function success returns a point to the Service Control Manager

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.