如果获得内存中运行的程序的完整路径?(50分)

  • 主题发起人 主题发起人 loginfree
  • 开始时间 开始时间
L

loginfree

Unregistered / Unconfirmed
GUEST, unregistred user!
自己先顶一下!希望大家支持,会的麻烦告诉小弟,不会的麻烦帮助顶一下,谢谢啦。。。
 
uses<br>&nbsp; TlHelp32;<br>procedure TMainForm.GetNewProcessList;<br>var<br>&nbsp; ProcessSnapShotHandle: THandle;<br>&nbsp; ProcessEntry: TProcessEntry32;<br>&nbsp; ProcessHandle: THandle;<br>&nbsp; Ret: BOOL;<br>&nbsp; s: string;<br>&nbsp; ModuleSnapShotHandle: THandle;<br>&nbsp; ModuleEntry: TModuleEntry32;<br>begin<br>&nbsp; ProcessSnapShotHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);<br>&nbsp; if ProcessSnapShotHandle&gt;0 then<br>&nbsp; begin<br>&nbsp; &nbsp; ProcessEntry.dwSize:=SizeOf(TProcessEntry32);<br>&nbsp; &nbsp; Ret:=Process32First(ProcessSnapShotHandle, ProcessEntry);<br>&nbsp; &nbsp; while Ret do<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; ModuleSnapShotHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, ProcessEntry.th32ProcessID);<br>&nbsp; &nbsp; &nbsp; if ModuleSnapShotHandle&gt;0 then<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; ModuleEntry.dwSize:=SizeOf(TModuleEntry32);<br>&nbsp; &nbsp; &nbsp; &nbsp; Ret:=Module32First(ModuleSnapShotHandle, ModuleEntry);<br>&nbsp; &nbsp; &nbsp; &nbsp; if Ret then<br>&nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s:=ModuleEntry.szExePath;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CloseHandle(ModuleSnapShotHandle)<br>&nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; Ret:=Process32Next(ProcessSnapShotHandle, ProcessEntry)<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; CloseHandle(ProcessSnapShotHandle);<br>&nbsp; end<br>end;<br><br>s就是你想要的。
 
OK啦,谢谢LeeChange。结帖了!
 
后退
顶部