function CheckSQL: Integer; var SCManager: THandle; HService: THandle; ServiceStatus: TServiceStatus; ServiceName: string; begin ServiceName:='主动防御'; SCManager := OpenSCManager(nil, nil, SC_MANAGER_ALL_ACCESS); if SCManager <> 0 then begin HService := OpenService(SCManager, PChar(ServiceName), GENERIC_READ); if HService <> 0 then begin if ControlService(HService, SERVICE_CONTROL_INTERROGATE, ServiceStatus) then begin if ServiceStatus.dwCurrentState = SERVICE_RUNNING then Result := 0 //运行 else Result := 2; //暂停 end else Result := 1; //停止 end else Result := -1; //没有服务 CloseServiceHandle(HService); CloseServiceHandle(SCManager); end;
----------------------------------------------
-