给段代码你参考,至于这么提取有用的信息,自己搞定。。//获得Dll被加载的所有进程ID和路径 {function GetDllHostAppPath(DllPath:string; var ProcIDArr:TArrCardinal; var ArrPath:TArrPChar;var iNum:integer):boolean; var ContinueLoop, MContinueLoop: BOOL; FSnapshotHandle, MFSnapshotHandle: THandle; FProcessEntry32: TProcessEntry32; ModuleEntry32 : TModuleEntry32; bGet:boolean; iProcCount:integer; sDllPath,sProcPath:string; begin try SetLength(ProcIDArr,0); SetLength(ArrPath,0); iNum:=0;
FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); FProcessEntry32.dwSize := Sizeof(FProcessEntry32); ContinueLoop := Process32First(FSnapshotHandle,FProcessEntry32); while integer(ContinueLoop) <> 0 do begin bGet:=False; MFSnapshotHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,FProcessEntry32.th32ProcessID); ModuleEntry32.dwSize:=sizeof(TModuleEntry32); MContinueLoop:=Module32First(MFSnapshotHandle,ModuleEntry32); while integer(MContinueLoop) <> 0 do begin sDllPath:=GetDllPath(ModuleEntry32.hModule); bGet:=UpperCase(sDllPath)=UpperCase(DllPath); if bGet then Break; MContinueLoop:=Module32Next(MFSnapshotHandle,ModuleEntry32); end; if bGet then begin sProcPath:=GetProcessPath(FProcessEntry32.th32ProcessID); if sProcPath<>'' then begin iProcCount:=Length(ProcIDArr); SetLength(ProcIDArr,iProcCount+1); SetLength(ArrPath,iProcCount+1); ProcIDArr[iProcCount]:=FProcessEntry32.th32ProcessID; Move(PChar(sProcPath)^,ArrPath[iProcCount],Length(sProcPath)); Inc(iNum); end; end; ContinueLoop := Process32Next(FSnapshotHandle,FProcessEntry32); end; result:=True; except result:=False; end; end;
详细请参考windows程序设计
vc tool 中的depends工具试试
{function GetDllHostAppPath(DllPath:string; var ProcIDArr:TArrCardinal; var ArrPath:TArrPChar;var iNum:integer):boolean;
var
ContinueLoop,
MContinueLoop: BOOL;
FSnapshotHandle,
MFSnapshotHandle: THandle;
FProcessEntry32: TProcessEntry32;
ModuleEntry32 : TModuleEntry32;
bGet:boolean;
iProcCount:integer;
sDllPath,sProcPath:string;
begin
try
SetLength(ProcIDArr,0);
SetLength(ArrPath,0);
iNum:=0;
FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
FProcessEntry32.dwSize := Sizeof(FProcessEntry32);
ContinueLoop := Process32First(FSnapshotHandle,FProcessEntry32);
while integer(ContinueLoop) <> 0 do
begin
bGet:=False;
MFSnapshotHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,FProcessEntry32.th32ProcessID);
ModuleEntry32.dwSize:=sizeof(TModuleEntry32);
MContinueLoop:=Module32First(MFSnapshotHandle,ModuleEntry32);
while integer(MContinueLoop) <> 0 do
begin
sDllPath:=GetDllPath(ModuleEntry32.hModule);
bGet:=UpperCase(sDllPath)=UpperCase(DllPath);
if bGet then Break;
MContinueLoop:=Module32Next(MFSnapshotHandle,ModuleEntry32);
end;
if bGet then
begin
sProcPath:=GetProcessPath(FProcessEntry32.th32ProcessID);
if sProcPath<>'' then
begin
iProcCount:=Length(ProcIDArr);
SetLength(ProcIDArr,iProcCount+1);
SetLength(ArrPath,iProcCount+1); ProcIDArr[iProcCount]:=FProcessEntry32.th32ProcessID;
Move(PChar(sProcPath)^,ArrPath[iProcCount],Length(sProcPath));
Inc(iNum);
end;
end; ContinueLoop := Process32Next(FSnapshotHandle,FProcessEntry32);
end;
result:=True;
except
result:=False;
end;
end;