begin schSCManager := OpenSCManager(PChar('Comp1'), //имя компьютера, nil - local machine nil, // ServicesActive database SC_MANAGER_ALL_ACCESS); // full access rights
if schSCManager = 0then exit; //Ошибка?
schService := OpenService( schSCManager, // SCM database PChar('SQLServerAgent'), // посмотри имя в Services. В данном случае - MS Server Agent SERVICE_ALL_ACCESS);
if schService = 0then exit; //Ошибка?
ifnot QueryServiceStatus( schService, // handle to service ssStatus) then// address of status information structure exit; //Ошибка?
case ssStatus.dwCurrentState of : SERVICE_RUNNING: ShowMessage('Работает!'); SERVICE_STOPPED: ShowMessage('Выключен'); // ну и т.д. end; end;