Hola a todos, en encontrado este procedimiento para detener un servicio de Windwes
Código Delphi
[-]
uses WinSvc;
procedure StopService(Nombre: String);
var
ServiceControlManager: SC_HANDLE;
Service: SC_HANDLE;
ServiceStatus: SERVICE_STATUS;
begin
ServiceControlManager:= OpenSCManager(nil, nil, SC_MANAGER_CONNECT);
if ServiceControlManager <> 0 then
begin
Service:= OpenService(ServiceControlManager,PChar(Nombre),SERVICE_ALL_ACCESS);
if Service <> 0 then
begin
if QueryServiceStatus(Service, ServiceStatus) then
begin
if ServiceStatus.dwCurrentState <> SERVICE_STOPPED then
ControlService(Service, SERVICE_CONTROL_STOP, ServiceStatus);
end;
CloseServiceHandle(Service);
end;
CloseServiceHandle(ServiceControlManager);
end;
end;
ejemplo de llamada
lo he probado en Windows 7 y 2008 Server y no me funciona, el revicio esta iniciado y nunca se detiene
Gracias por sus comentarios