The Win32 API methods for the Service Control Manager are powerful but rather unwieldy. Download the Delphi unit service.pas which contains wrapper functions for QueryServiceStatus(), StartService() and ControlService().
- service.pas (4KB)
See the interface section for the unit below, hopefully it's all self explanatory.
unit service;
// Some useful wrapper functions for NT Services.
// Geoffrey Swift (c) 2006
interface
uses Windows;
function GetServiceStatus(const ServiceName: String): DWORD;
function StartService(const ServiceName: String; const Wait: Boolean): DWORD;
function StopService(const ServiceName: String; const Wait: Boolean): DWORD;