P
pub66cn
Unregistered / Unconfirmed
GUEST, unregistred user!
我对服务安装与启动部份不太熟悉。。
请牛牛们帮忙译一下以下代码为delphi
int main(int argc,char **argv)
{
printf("Load Driver/n");
HANDLE scm=OpenSCManager(NULL,NULL,SC_MANAGER_CREATE_SERVICE);
if(scm)
{
printf("Create Service/n");
HANDLE svc=CreateService(scm,argv[1],argv[2],SERVICE_START | DELETE | SERVICE_STOP,SERVICE_KERNEL_DRIVER,
SERVICE_DEMAND_START,SERVICE_ERROR_IGNORE,argv[3],NULL,NULL,NULL,NULL,NULL);
if(!svc) svc=OpenService(scm,argv[1],SERVICE_START | DELETE | SERVICE_STOP);
if(svc)
{
printf("Starting service/n");
StartService(svc,0,NULL);
printf("Press Enter to stop and delete service /n");
getchar();
SERVICE_STATUS status;
ControlService(svc,SERVICE_CONTROL_STOP,&status);
DeleteService(svc);
CloseServiceHandle(svc);
} else printf("error: unable to create/open service/n");
CloseServiceHandle(scm);
} else printf("error: unable to open manager/n");
return 0;
}
请牛牛们帮忙译一下以下代码为delphi
int main(int argc,char **argv)
{
printf("Load Driver/n");
HANDLE scm=OpenSCManager(NULL,NULL,SC_MANAGER_CREATE_SERVICE);
if(scm)
{
printf("Create Service/n");
HANDLE svc=CreateService(scm,argv[1],argv[2],SERVICE_START | DELETE | SERVICE_STOP,SERVICE_KERNEL_DRIVER,
SERVICE_DEMAND_START,SERVICE_ERROR_IGNORE,argv[3],NULL,NULL,NULL,NULL,NULL);
if(!svc) svc=OpenService(scm,argv[1],SERVICE_START | DELETE | SERVICE_STOP);
if(svc)
{
printf("Starting service/n");
StartService(svc,0,NULL);
printf("Press Enter to stop and delete service /n");
getchar();
SERVICE_STATUS status;
ControlService(svc,SERVICE_CONTROL_STOP,&status);
DeleteService(svc);
CloseServiceHandle(svc);
} else printf("error: unable to create/open service/n");
CloseServiceHandle(scm);
} else printf("error: unable to open manager/n");
return 0;
}