Driver loading.

Source: Internet
Author: User

To load the driver properly, follow these steps:

1. Call openscmanager to open the SCM manager. If null is returned, an error is returned; otherwise, the next step is continued;

2. Call createservice to create a service. If the returned value obtained by getlasterror is error_io_pending, it indicates that the service has been created and openservice is used to open the service.

3. Call startservice to enable the Service.

Openscmanager --> createservice --> openservice --> startservice --> closeservicehandle

SC _handle openscmanager (

Lpctstr Lpmachinename,
// Point to the computer name. null indicates pointing to the local machine.
 

Lpctstr Lpdatabasename,
// SCM database name. The default value is null.

 DWORD Dwdesiredaccess// The permission is generally set to SC _manager_all_access, indicating that all permissions are granted.

);

// The SCM handle to close

Boolcloseservicehandle (SC _handle Hscobject)

// Open the Service Control Manager

Openscmanager (null, null, SC _manager_all_access );

 

// Create the service corresponding to the driver

Createservice (hservicemgr, // SCM manager handle

Lpszdrivername, // name of the driver in the Registry

Lpszdrivername, // displayname value of the registry driver

Service_all_access, // access permission for loading the driver

Service_kernel_driver, // indicates that the loaded service is a driver.

Service_demand_start, // The start value of the registry driver

Service_error_ignore, // The errorcontrol value of the registry driver

Szdriverimagepath, // The ImagePath value of the registry driver

Null, // user group to enable the Service

Null, // output validation tag

Null, // The Name Of The dependent service

Null, // User Account Name

Null); // User Password

 

// The driver has been loaded. You only need to open

Openservice (hservicemgr, lpszdrivername, service_all_access );

// Enable this service

Startservice (hserviceddk, null, null );

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.