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版inf方式加载驱动

Delphi 进程防杀之hook api法

我的Delphi开发经验谈

Delphi hash类

Delphi downloadtomemory

Delphi 线程中修改主窗体的控件内容

Delphi测试数据库连接时间

tstringgrid 添加鼠标拖动功能

Delphi xe 提示没有定义decimalseparator等的解决方法

Delphi中单独编译pas生成dcu文件

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



打赏

取消

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

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

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

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

评论

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