本文整理自网络,侵删。
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. 相关阅读 >>
rad studio Delphi创建安卓服务creating android services
Delphi xe5 json与Delphi object的互换
更多相关阅读请进入《Delphi》频道 >>