Einzelnen Beitrag anzeigen

Benutzerbild von Zacherl
Zacherl

Registriert seit: 3. Sep 2004
4.629 Beiträge
 
Delphi 10.2 Tokyo Starter
 
#8

Re: Handle einer DLL rausfinden

  Alt 18. Aug 2008, 17:25
Auf die Schnelle:

Delphi-Quellcode:
procedure TForm2.Button1Click(Sender: TObject);
var
  hSnapshot,
  PID: Cardinal;
  Proc32: TProcessEntry32;
  Mod32: TModuleEntry32;
begin
  PID := 0;

  hSnapshot := TlHelp32.CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  if (hSnapshot <> 0) and (hSnapshot <> INVALID_HANDLE_VALUE) then
  begin
    try
      if Process32First(hSnapshot, Proc32) then
      begin
        while Process32Next(hSnapshot, Proc32) do
        begin
          if AnsiUppercase(Proc32.szExeFile) = 'QIP.EXEthen
          begin
            PID := Proc32.th32ProcessID;
            Break;
          end;
        end;
      end;
    finally
      CloseHandle(hSnapshot);
    end;
  end;

  if PID <> 0 then
  begin
    hSnapshot := TlHelp32.CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, PID);
    if (hSnapshot <> 0) and (hSnapshot <> INVALID_HANDLE_VALUE) then
    begin
      try
        if Module32First(hSnapshot, Mod32) then
        begin
          while Module32Next(hSnapshot, Mod32) do
          begin
            if AnsiUppercase(Mod32.szModule) = 'PLUGIN.DLLthen
            begin
              // Modul Handle steht jetzt in
              // Mod32.hModule
              Break;
            end;
          end;
        end;
      finally
        CloseHandle(hSnapshot);
      end;
    end;
  end;
end;
  Mit Zitat antworten Zitat