function GetImagePath(PID:dword):string;<br> var<br> ProcHand: THandle; //进程的句柄<br> ModHand: array[0..1024] of HMODULE; //模块的句柄<br> ModName: array[0..MAX_PATH] of char;//模块文件名<br> count:dword;<br>begin<br> result:='';<br> ProcHand := OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ,<br> False, PID);<br> if ProcHand=ERROR_INVALID_ACCESS then exit;<br> //列举进程所有的模块<br> EnumProcessModules(Prochand, @ModHand,sizeof(ModHand) , Count);<br> try<br> //取第一个模块名就是进程路径<br> if GetModuleFileNameEx(ProcHand, ModHand[0], ModName,SizeOf(ModName)) > 0 then<br> begin<br> result:=strpas(modname);<br> end;<br> finally<br> CloseHandle(ProcHand);<br> end;<br>end;