¿Alguien me puede explicar dónde está el error en esta función? En ella compruebo la existencia de un servicio y si no existe intento crearlo (¡y aquí está el error!)
Código Delphi
[-]
function CrearServicioApache : boolean;
var
ServicioControl : SC_Handle;
Servicio : SC_Handle;
Path : string;
begin
Result := False;
ServicioControl := OpenSCManager(nil, nil, SC_MANAGER_CONNECT);
if ServicioControl <> 0 then
begin
Servicio := OpenService(ServicioControl, 'Apache 2', SERVICE_ALL_ACCESS);
if Servicio <> 0 then
CloseServiceHandle(Servicio)
else begin
path := '"c:\apache\apache2\bin\apache.exe" -k runservice';
Servicio := CreateService(ServicioControl,
'Apache 2', 'Servidor Apache',
SC_MANAGER_ALL_ACCESS or SC_MANAGER_CREATE_SERVICE,
SERVICE_WIN32_OWN_PROCESS,
SERVICE_DEMAND_START,
SERVICE_ERROR_IGNORE,
PChar(Path), nil, nil, nil, nil, nil);
if Servicio <> 0 then
begin
Result := True;
CloseServiceHandle(Servicio);
end;
end;
CloseServiceHandle(ServicioControl);
end;
end;
Postdata: Sistema operativo WINDOWS XP