Ver Mensaje Individual
  #1  
Antiguo 08-01-2008
MON___ MON___ is offline
Miembro
 
Registrado: abr 2007
Ubicación: Salamanca (España)
Posts: 84
Reputación: 18
MON___ Va por buen camino
No me crea el SERVICIO

¿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  //no existe el servicio e intento crearlo
    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

Última edición por jachguate fecha: 09-01-2008 a las 02:38:59. Razón: Etiqueta code
Responder Con Cita