Ver Mensaje Individual
  #2  
Antiguo 23-09-2005
Avatar de jmariano
jmariano jmariano is offline
Miembro
 
Registrado: jul 2005
Posts: 376
Reputación: 19
jmariano Va por buen camino
No se como estarás invocando la función pero te pongo un código que encontré sobre este tema y que, según su autor, funciona en el Windows Server 2003 (es necesario entrar con una cuenta local de administrador):

Código Delphi [-]
function ServiceGetList(sMachine: string; slServicesList: TStrings): Boolean;
type
  TSvcA = array[0..0] of TEnumServiceStatus;
  PSvcA = ^TSvcA;
var
  j: integer;
  schm: SC_Handle;
  nBytesNeeded, nServices, nResumeHandle: Cardinal;
  ssa: PSvcA;
begin
  Result := False;
  
  try
    schm := OpenSCManager(PChar(sMachine), nil, SC_MANAGER_ENUMERATE_SERVICE);

    if schm <> 0 then
      begin
        nResumeHandle := 0;
        nServices := 0;
        nBytesNeeded := 0;
        ssa := nil;
      
        EnumServicesStatus(schm, SERVICE_TYPE_ALL, SERVICE_STATE_ALL, ssa[0],
          SizeOf(ssa), nBytesNeeded, nServices, nResumeHandle);
          
        GetMem(ssa, nBytesNeeded);
        
        EnumServicesStatus(schm, SERVICE_TYPE_ALL, SERVICE_STATE_ALL, ssa[0],
          nBytesNeeded, nBytesNeeded, nServices, nResumeHandle);
          
        for j := 0 to nServices - 1 do
          begin
            slServicesList.Add(StrPas(ssa[j].lpDisplayName));
            slServicesList.Add(StrPas(ssa[j].lpServiceName));
          end;
          
        Result := True;
        FreeMem(ssa);
        CloseServiceHandle(schm);
      end;
  except
  end;
end;

Saludos!

Última edición por jmariano fecha: 23-09-2005 a las 12:57:50.
Responder Con Cita