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 的tstringbuilder防止服务器内存碎片化

Delphi xe7 判断android应用程序中的通信状态类型

Delphi 将string 转为 array of ansichar

Delphi xe2支持zip压缩文件的操作了

Delphi复制整个文件夹(当然包括嵌套文件夹)

Delphi xe中 exit 的新用法

Delphi程序版本信息设置说明

Delphi 多种方法查找窗口句柄

Delphi中如何向某个ip不间断的发送数据

Delphi getwindowhandle

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



打赏

取消

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

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

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

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

评论

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