// fuente stackoverflow how-//to-get-a-list-of-used-dlls  y la internet misma
 {$WARN SYMBOL_PLATFORM OFF} //fix warning in delphi7
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,TlHelp32,psapi;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Button1: TButton;
    Edit1: TEdit;
    Label1: TLabel;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}


///********PSAPI************
function listModules( processID:DWORD ):string;

 var
 i:integer;
 ModuleNam: Array[0..1024] of Char;
 fullname: Array[0..1024] of Char;
 hMods :  array [0..1024]of HMODULE;
 hProcess:thandle;
 cbNeeded:dword;
    begin

     processID:=strtoint(form1.edit1.text );
   // Get a handle to the process.

    hProcess := OpenProcess( PROCESS_QUERY_INFORMATION or
                            PROCESS_VM_READ,
                            FALSE, processID );
    if (hProcess <> 0) then   begin

    EnumProcessModules(hProcess, @hMods, sizeof(hMods), cbNeeded);
        // Get a list of all the modules in this process.
     for i := 0 to (cbNeeded div SizeOf(HMODULE) - 1) do //display all module
            begin
              // Get the full path to the module's file.
              GetModuleBaseNameA(hProcess, hMods[i], ModuleNam, SizeOf(ModuleNam));
              GetModuleFileNameExA(hProcess, hMods[i], FullName, SizeOf(ModuleNam));
          FORM1.memo1.lines.add(  StrPas(ModuleNam) +'  '+StrPas(FullName));
                                          
          //  Result :=	result + #13#10 +#9' '+  StrPas(ModuleNam) +#9' '+StrPas(FullName);
 end;
 end;
CloseHandle( hProcess );
end;



          //******el otro metodo
procedure TForm1.Button1Click(Sender: TObject);
var

 path:string;
pid: dword;
  Handle,Process: THandle;
  ModuleEntry: TModuleEntry32;
begin
    pid:=strtoint(edit1.Text);





Handle := CreateToolHelp32SnapShot(TH32CS_SNAPMODULE, pid);
Win32Check(Handle<>0);
  try
    ModuleEntry.dwSize := Sizeof(ModuleEntry);
    Win32Check(Module32First(Handle, ModuleEntry));



    repeat
    memo1.Lines.add(ModuleEntry.szModule);
    memo1.Lines.add(ModuleEntry.szExePath);

    until not Module32Next(Handle, ModuleEntry);

  finally
    CloseHandle(Handle);

  end;

   end;



procedure TForm1.Button2Click(Sender: TObject);
begin
listModules(strtoint(edit1.Text));
end;
paresco malo ,pero soy bueno
Responder

Volver a “Fuentes”