本文整理自网络,侵删。
unit Unit1;
interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls, psapi;type
TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); function GetProcessPath(ProcessID: DWORD): string; private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.dfm}
function TForm1.GetProcessPath(ProcessID: DWORD): string;var Hand: THandle; ModName: Array[0..Max_Path-1] of Char; hMod: HModule; n: DWORD;begin Result:=''; Hand:=OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ, False, ProcessID); if Hand>0 then try ENumProcessModules(Hand,@hMod,Sizeof(hMod),n); if GetModuleFileNameEx(Hand,hMod,ModName,Sizeof(ModName))>0 then Result:=ExtractFilePath(ModName); except end;end;
procedure TForm1.Button1Click(Sender: TObject);vars:string;begins:=GetProcessPath(852);showmessage(s);end;end.
相关阅读 >>
Delphi xe增强的rtti妙用--动态创建包中的窗口类
Delphi cannot find implementation of method formcreate 解决办法
Delphi 关于 beep、messagebeep 和 windows.beep
更多相关阅读请进入《Delphi》频道 >>