楚楚留香
级别:精灵王 威望:6 经验:1 货币:2090 体力: 来源:202.98.177.* 总发帖数:590 注册日期:2001-04-17
|
|
查看 邮件 主页 QQ 消息 引用 复制 下载
SC_HANDLE
scm,sHandle; SERVICE_STATUS ServiceStatus;
scm=OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS); if
(scm!=NULL) { //启动service
sHandle=OpenService(scm,"GwbnService",SERVICE_START);
if(sHandle!=NULL) {
StartService(sHandle,0,NULL))//开始Service } //停止Service
sHandle=OpenService(scm,"GwbnService",SERVICE_STOP|SERVICE_QUERY_STATUS);
if(sHandle!=NULL)
QueryServiceStatus(sHandle,&ServiceStatus);
if(ServiceStatus.dwCurrentState == SERVICE_RUNNING ||
ServiceStatus.dwCurrentState == SERVICE_PAUSED) {
ControlService(sHandle,SERVICE_CONTROL_STOP,&ServiceStatus);
} //暂停Service
sHandle=OpenService(scm,"GwbnService",SERVICE_PAUSE_CONTINUE|SERVICE_QUERY_STATUS);
if(sHandle!=NULL)
QueryServiceStatus(sHandle,&ServiceStatus);
if(ServiceStatus.dwCurrentState == SERVICE_RUNNING) {
ControlService(sHandle,SERVICE_CONTROL_PAUSE,&ServiceStatus);
} //继续Service
sHandle=OpenService(scm,"GwbnService",SERVICE_PAUSE_CONTINUE|SERVICE_QUERY_STATUS);
if(sHandle!=NULL)
QueryServiceStatus(sHandle,&ServiceStatus);
if(ServiceStatus.dwCurrentState == SERVICE_PAUSED) {
ControlService(sHandle,SERVICE_CONTROL_CONTINUE,&ServiceStatus);
}
|