本文整理自网络,侵删。
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中转向语句break,continue,exit的作用
Delphi d10.x 在安卓app开发中使用jar包的注意事项
Delphi readprocessmemory writeprocessmemory读写内存
Delphi 如何将access的ole对象字段存储的bmp图象显示出来
更多相关阅读请进入《Delphi》频道 >>