Autor Beitrag
MrSaint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1033
Erhaltene Danke: 1

WinXP Pro SP2
Delphi 6 Prof.
BeitragVerfasst: So 19.09.04 17:40 
Hi!

Ich würde gern wissen, wie ich herausbekommen kann, welche DLLs im aktuellen Prozess bereits dynamisch geladen wurden. Gibt es da eine API-Funktion?


MfG


MrSaint

_________________
"people knew how to write small, efficient programs [...], a skill that has subsequently been lost"
Andrew S. Tanenbaum - Modern Operating Systems
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: So 19.09.04 18:31 
Hab mal ein C Beispiel aus dem Buch "Windows - Programmierung für Experten" von Jeffrey Richter umgeschrieben.
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
unit GetLoadedDLLs_Unit;

interface

uses
  Windows, SysUtils;

type
  TLoadedModule = record
    ModuleName: String;
    FullName: String;
    BaseAddress: THandle;
  end;
  TLoadedModules = array of TLoadedModule;
  PLoadedModules = ^TLoadedModules;

procedure GetLoadedDLLs(Modules: PLoadedModules);

implementation

procedure GetLoadedDLLs(Modules: PLoadedModules);
var
  Address: PByte;
  MBI: TMemoryBasicInformation;
  Size: LongWord;
  S: String;
begin

  Address := nil;
  Size := SizeOf(TMemoryBasicInformation);
  FillChar(MBI, Size, 0);
  SetLength(Modules^, 0);

  while (VirtualQuery(Address, MBI, Size) = Size) do
  begin

    if MBI.State = MEM_FREE then
      MBI.AllocationBase := MBI.BaseAddress;

    if (LongWord(MBI.AllocationBase) <> HInstance) and
       (MBI.AllocationBase = MBI.BaseAddress) and
       (MBI.AllocationBase <> nil)  then
    begin
      SetLength(S, MAX_PATH);
      SetLength(S, GetModuleFileName(THandle(MBI.AllocationBase), PChar(S), MAX_PATH));
      if Length(S) > 0 then
      begin
        SetLength(Modules^, Length(Modules^) + 1);
        with Modules^[High(Modules^)] do
        begin
          FullName := S;
          ModuleName := ExtractFileName(S);
          BaseAddress := THandle(MBI.AllocationBase);
        end;
      end;
    end{end if}

    inc(Address, MBI.RegionSize);

  end{end while}

end{end procedure}

end.

_________________
Ciao, Sprint.
MrSaint Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1033
Erhaltene Danke: 1

WinXP Pro SP2
Delphi 6 Prof.
BeitragVerfasst: So 19.09.04 18:36 
sehr cool, danke :)

MrSaint

_________________
"people knew how to write small, efficient programs [...], a skill that has subsequently been lost"
Andrew S. Tanenbaum - Modern Operating Systems