Ver Mensaje Individual
  #1  
Antiguo 20-06-2010
BrunoBsso BrunoBsso is offline
Miembro
 
Registrado: nov 2009
Ubicación: Berisso, Buenos Aires, Argentina
Posts: 239
Reputación: 15
BrunoBsso Va por buen camino
Question Lista de procesos... pero 64 bits?

Hola foro.
Alguno me dirá "esto ya se trató" y espero que me ponga el link, porque por más que busco acá y en google, no encuentro la respuesta.
Ante todo, aclaro que lo que les voy a mostrar me devuelve todos los procesos que se ejecutan con arquitectura de 32 bits.

Para SO Windows 9x:
Código Delphi [-]
procedure CreateWin9xProcessList(List: TstringList);
var
  hSnapShot: THandle;
  ProcInfo: TProcessEntry32;
begin
  if List = nil then Exit;
  hSnapShot := CreateToolHelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  if (hSnapShot <> THandle(-1)) then
  begin
    ProcInfo.dwSize := SizeOf(ProcInfo);
    if (Process32First(hSnapshot, ProcInfo)) then
    begin
      List.Add(ProcInfo.szExeFile);
      while (Process32Next(hSnapShot, ProcInfo)) do
        List.Add(ProcInfo.szExeFile);
    end;
    CloseHandle(hSnapShot);
  end;
end;

Para SO Windows NT:
Código Delphi [-]
procedure CreateWinNTProcessList(List: TstringList);
var
  PIDArray: array [0..1023] of DWORD;
  cb: DWORD;
  I: Integer;
  ProcCount: Integer;
  hMod: HMODULE;
  hProcess: THandle;
  ModuleName: array [0..300] of Char;
begin
  if List = nil then Exit;
  EnumProcesses(@PIDArray, SizeOf(PIDArray), cb);
  ProcCount := cb div SizeOf(DWORD);
  for I := 0 to ProcCount - 1 do
  begin
    hProcess := OpenProcess(PROCESS_QUERY_INFORMATION or
      PROCESS_VM_READ,
      False,
      PIDArray[i]);
    if (hProcess <> 0) then
    begin
      EnumProcessModules(hProcess, @hMod, SizeOf(hMod), cb);
      GetModuleFilenameEx(hProcess, hMod, ModuleName, SizeOf(ModuleName));
      List.Add(ModuleName);
      CloseHandle(hProcess);
    end;
  end;
end;

Método global:
Código Delphi [-]
procedure GetProcessList(var List: TstringList);
var
  ovi: TOSVersionInfo;
begin
  if List = nil then Exit;
  ovi.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
  GetVersionEx(ovi);
  case ovi.dwPlatformId of
    VER_PLATFORM_WIN32_WINDOWS: CreateWin9xProcessList(List);
    VER_PLATFORM_WIN32_NT: CreateWinNTProcessList(List);
  end
end;

Bueno, eso lo saqué de Torry creo, ya no me acuerdo. Siempre lo usé, porque siempre trabajé sobre 32 bits.
Ahora estoy necesitando obtener la lista de procesos en, por ejemplo, Windows 7 a 64 bits.
El problema es que llamando al global (GetProcessList) solamente me devuelve los procesos basados en 32 bits, y como que no soy muy bueno para entender las API de Windows
Espero que alguien me pueda ayudar.
Pregunta en concreto -> ¿Cómo obtengo también los procesos en 64 bits?
Saludos.
Responder Con Cita