下面的代码列出进程调用的所有模块
procedure TProcessInfo.EnumModules(const AList: TStrings);
var
snap : THandle;
me32 : TMODULEENTRY32;
begin
if FHandle = 0 then
//FHandle为进程PID
Exit;
snap := CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, FHandle);
if snap <> 0 then
try
me32.dwSize:= SizeOf(TMODULEENTRY32);
if Module32First(snap, me32) then
begin
AList.Add(AnalyzeFileName(me32.szExePath));
while Module32Next(snap, me32)do
AList.Add(AnalyzeFileName(me32.szExePath));
end;
finally
CloseHandle(snap);
end;
end;