本文整理自网络,侵删。
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 不管什么datetime日期格式时间格式转换都不会错了
Delphi xe5 for android 地理定位gps
Delphi 查看字符串在不同编码(ascii、unicode、utf7、utf8、default、bigendianunicode)下的 hex
Delphi 从 twebbrowser中获得当前输入处的链接
Delphi 判断两个时间差是否在一个指定范围内 -withinpastyears、withinpastmonths、withinpastweeks、withinpastdays
更多相关阅读请进入《Delphi》频道 >>