不知哪下的,感觉不错,上传给大家使用
function SartService(ServiceName: string) : boolean;
var
hSCM : HANDLE;
hService: HANDLE;
Status : SERVICE_STATUS;
begin
hSCM := OpenServiceManager();
Result := false;
if hSCM <> 0 then begin
hService := OpenService(hSCM,ServiceName,SERVICE_START);
if hService <> 0 then begin
Result := StartService(hService,0,'');
CloseServiceHandle(hService)
end;
CloseServiceHandle(hSCM)
end;
end;
1