//Establish a connection to the service control manager
SchSCManager = OpenSCManagerA (NULL, // machine (NULL == local)
NULL, // database (NULL == default)
SC_MANAGER_ALL_ACCESS // access required
);
if(SchSCManager != NULL)
{
SetDlgItemText(IDC_STATIC2, "打开schSCManager句柄成功");
}
else
{
SetDlgItemText(IDC_STATIC2, "打开schSCManager句柄失败");
return;
}
// Create a service object and add it to default service control
// manager database
schService = CreateService (SchSCManager, // SCManager database
DriverName, // name of service
DriverName, // name to display
SERVICE_ALL_ACCESS, // desired access
SERVICE_KERNEL_DRIVER, // service type
SERVICE_DEMAND_START, // start type
SERVICE_ERROR_NORMAL, // error control type
ServiceExe, // service's binary
NULL, // no load ordering group
NULL, // no tag identifier
DependOnServices, // no dependencies
NULL, // LocalSystem account
NULL // no password
);