I try to stop a windows service with the below code,but Services.StopService('Spooler',false) always release a error message,anyone know what wrong with it
Services := TServiceManager.Create(nil);
try
Services.Acces := SC_MANAGER_CONNECT;
Services.Connect;
Services.GetServiceStatus('Spooler', ServiceStatus);
svc_act := (ServiceStatus.dwCurrentState = SERVICE_RUNNING);
if svc_act then
Services.StopService('Spooler',false);
Services.Disconnect;
finally
Services.Free;
end;