急:API函数StartService()的用法?
代码如下:
SC_HANDLE hService,hSCManager;
hService=NULL;
if ((hSCManager=OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS)) == NULL){
Application->MessageBox("打开系统服务控制台失败!","出错信息",0);
CloseServiceHandle(hSCManager);
return;
}
if ((hService=OpenService(hSCManager,"CustomReqTransService",SERVICE_START)) == NULL){
Application->MessageBox("打开服务失败!","出错信息",0);
CloseServiceHandle(hService);
CloseServiceHandle(hSCManager);
return;
}
if (StartService(hService,0,NULL) == 0){
Application->MessageBox("服务启动失败!","出错信息",0);
CloseServiceHandle(hService);
CloseServiceHandle(hSCManager);
return;
}
Application->MessageBox("服务启动成功,请用系统的服务控制台查看!","信息",0);
CloseServiceHandle(hService);
CloseServiceHandle(hSCManager);
但StartService(hService,0,NULL)的执行不能成功,请问如何解决?