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 无法结束进程的程序

Delphi tfinddialog treplacedialog对话框在memo中的使用

Delphi sha1加密函数

Delphi xe string与tstringbuilder的关系

Delphi lockbox 做加密解密

Delphi 15位身份证号码转18位身份证号码

Delphi xe 安卓开发黑屏的另一种解决办法

Delphi rest服务器返回图像并显示在浏览器中

Delphi readln 读取一行文本

Delphi 7 中dbgrid的排序

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



打赏

取消

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

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

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

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

评论

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