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 tidhttp 超时的解决方案

Delphi 如何将多个文件复制到一个

Delphi upload 上传文件

Delphi 禁用启用网卡

Delphi: ttreeview 中禁止双击事件展开或关闭节点

Delphi 拼接文件路径

Delphi xe5实现datetimetounix/unixtodatetime的一点小改进

Delphi生成32位随机数

Delphi 数据类型列表

Delphi indy tidhttp tidhttpserver post get

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



打赏

取消

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

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

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

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

评论

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