delphi 获得指定进程的ID号


本文整理自网络,侵删。

 {delphi 获得指定进程的ID号。}
function GetProcessIDFromExename(ExeName: string): Cardinal;
const
PROCESS_TERMINATE = $0001;
var
ContinueLoop: BOOLEAN;
FSnapshotHandle: THandle;
FProcessEntry32: TProcessEntry32;
begin
Result := 0;
FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
FProcessEntry32.dwSize := SizeOf(FProcessEntry32);
ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
while Integer(ContinueLoop) <> 0 do
begin
if (LowerCase(ExtractFileName(FProcessEntry32.szExeFile)) =
LowerCase(ExeName)) then
Result := FProcessEntry32.th32ProcessID;
ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
end;
CloseHandle(FSnapshotHandle);
end;

相关阅读 >>

Delphi 10 下提示sharedactivitycontext错误的解决方法

Delphi Delphi copy,pos,delete win api 版

Delphi trayicon1如何把窗体关闭到系统托盘

Delphi 闪盘小偷

Delphi 虚拟键码对照表

Delphi http json 验证token

Delphi 获取 access 数据库所有表

Delphi 限制form窗体为固定的大小

Delphi 3句话绕过xxx拦截删除桌面快捷方式

Delphi chart组件,chart控件用法

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



打赏

取消

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

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

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

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

评论

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