诶 刚失恋没什么好做的 无聊帮你写一个 应该说是帮抄一个。<br>只示范了在已知进程ID的情况下取得本应用程序所有模块列表。<br>其他信息可以在变量 ModuleStruct 里获得。<br><br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls, ExtCtrls;<br><br>Const<br> TH32CS_SNAPMODULE = $00000008; // 模块列表快照<br>Type<br> {-- 枚举中 返回 模块信息结构 --}<br> TMODULEENTRY32 = record<br> dwSize: DWORD; // 本结构尺寸<br> th32ModuleID: DWORD; // This module<br> th32ProcessID: DWORD; // owning process<br> GlblcntUsage: DWORD; // Global usage count on the module<br> ProccntUsage: DWORD; // Module usage count in th32ProcessID's context<br> modBaseAddr: PBYTE; // Base address of module in th32ProcessID's context<br> modBaseSize: DWORD; // Size in bytes of module starting at modBaseAddr<br> hModule: HMODULE; // The hModule of this module in th32ProcessID's context<br> szModule: array[0..255] of Char;<br> szExePath: array[0..260 - 1] of Char;// 模块完整路径<br> end;<br><br> TForm1 = class(TForm)<br> Memo1: TMemo;<br> Panel1: TPanel;<br> Button1: TButton;<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br> function CreateToolhelp32Snapshot(dwFlags, th32ProcessID: DWORD) : THandle ; stdcall; external 'kernel32.dll' name 'CreateToolhelp32Snapshot';<br> function Module32First(hSnapshot: THandle; var lpme: TModuleEntry32): BOOL ; stdcall; external 'kernel32.dll' name 'Module32First';<br> function Module32Next(hSnapshot: THandle; var lpme: TModuleEntry32): BOOL ; stdcall; external 'kernel32.dll' name 'Module32Next';<br><br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var <br> ModuleStruct : TMODULEENTRY32; // 模块信息结构<br> ModuleHandle : LongWord; // 快照句柄<br> FoundModule : Boolean ; // 是否找到模块<br> FullFileName : string ; // 完整路径<br> WinProcessId : LongWord; // 进程id<br>Begin<br> {---模块列表快照---}<br> WinProcessId := 4564;<br> ModuleHandle := CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, WinProcessId);<br> ModuleStruct.dwSize := sizeof(ModuleStruct); <br> {----第1个模块----}<br> FoundModule := Module32First(ModuleHandle, ModuleStruct);<br> while (FoundModule) do<br> begin<br> FullFileName:=ModuleStruct.szExePath;<br> //FULLFILENAME 就是你要的文件名 你可以自己处理。<br> memo1.Lines.Add(FullFileName);<br> {----下一个模块----}<br> FoundModule := Module32Next(ModuleHandle, ModuleStruct);<br> end;<br> {----释放句柄----}<br> CloseHandle(ModuleHandle);<br>end;<br><br>end.