Delphi GetExplorerPID获取系统explorer.exe进程ID


本文整理自网络,侵删。

 

//单元文件 TLHelp32   获取explorer.exe进程ID 同样也可以获取任何进程ID

function GetExplorerPID(const AExeName: string): int64;

var

ProcessName : string; //进程名

ProcessID : integer; //进程表示符

i : integer;

ContinueLoop:BOOL;

FSnapshotHandle:THandle; //进程快照句柄

FProcessEntry32:TProcessEntry32; //进程入口的结构体信息

begin

FSnapshotHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0); //创建一个进程快照

FProcessEntry32.dwSize:=Sizeof(FProcessEntry32);

ContinueLoop:=Process32First(FSnapshotHandle,FProcessEntry32); //得到系统中第一个进程

//循环例举 www.delphitop.com 

while ContinueLoop do

begin

ProcessName := FProcessEntry32.szExeFile;

ProcessID := FProcessEntry32.th32ProcessID;

//result :=result+inttostr(ProcessID)+ProcessName;

if pos(UpperCase(ProcessName),UpperCase(AExeName))>0 then

begin

result :=ProcessID;

break;

end

else

begin

result :=0;

end;

ContinueLoop:=Process32Next(FSnapshotHandle,FProcessEntry32);

end;

end;

相关阅读 >>

Delphi 动态调用chm文件

Delphi 利用tidencodermime tiddecodermime 组件字符串加密解密

Delphi getwindowtext - 获取窗口标题

Delphi gif 动画建立

Delphi内嵌汇编语言basm精要

Delphi 三个消息函数的威力

Delphi判断文件夹(目录)是否存在,不存在就创建的办法

Delphi判断字符串是否是数字、字母、大小写字母

Delphi d10.x 在android 9及更高版本下使用Delphi获取设备序列号?

Delphi 采用 tidhttp 访问 https 的网站,采用 tidtcpclient 访问 https 的网站

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



打赏

取消

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

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

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

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

评论

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