Delphi通过进程名获取进程PID函数


本文整理自网络,侵删。

 
uses TLhelp32;

Function GetPID(_GetPID:String):String;
var
     h:thandle;
     f:boolean;
     lppe:tprocessentry32;
begin
     h := CreateToolhelp32Snapshot(TH32cs_SnapProcess, 0);
     lppe.dwSize := sizeof(lppe);
     f := Process32First(h, lppe);     //lppe.szExeFile是进程的名字,自己挑选你要的
     //lppe.th32ProcessID就是你要的进程号
     while integer(f) <> 0 do
     begin
       //if lppe.szExeFile=‘QQ.exe‘ then showmessage(‘ok‘);
       if lppe.szExeFile = _GetPID then
       begin
         Result:=(inttostr(lppe.th32ProcessID));
         break;
       end;
       f := Process32Next(h, lppe);
     end;
end;

相关阅读 >>

Delphi 服务器与客户端的时间同步

Delphi opendialog文件多选

Delphi 如何从dll中检索导出函数的列表

Delphi if语法,弹出提示框,不等于写法,判断是否为空

Delphi 如何确定活动桌面是否已启用

Delphi(更改图标)

Delphi net.httpclient正则批量获取网页代码中的数值

Delphi + word = 数据库 + 公文处理

Delphi dbgrid查询内容的导出为txt函数

Delphi 无法结束进程的程序

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...