delphi 检查父进程


本文整理自网络,侵删。

 delphi 检查父进程 

{uses TLHelp32}
procedure CheckParentProc;
var
Pn: TProcesseNtry32;
sHandle: THandle;
ParentProc: HWND;
Found: Boolean;
begin
ParentProc := 0;

sHandle := CreateToolHelp32SnapShot(TH32CS_SNAPALL, 0);
try
Found := Process32First(sHandle, Pn); //Search process
while Found do //Loop all processes
begin
if CompareText(ExtractFileName(Pn.szExeFile), ExtractFileName(ParamStr(0))) = 0 then //It's me
begin
ParentProc := Pn.th32ParentProcessID; //Get parent process ID
Break;
end;

Found := Process32Next(sHandle, Pn); //Find next
end;

if ParentProc > 0 then //Valid
begin
Found := Process32First(sHandle, Pn);
while Found do
begin
if Pn.th32ProcessID = ParentProc then //It's my parent process
begin
ParentProc := Pn.th32ParentProcessID; //Get its parent process, my grandfather process :)
Break;
end;

Found := Process32Next(sHandle, Pn); //Find next
end;

if ParentProc > 0 then
begin
Found := Process32First(sHandle, Pn);
while Found do
begin
if Pn.th32ProcessID = ParentProc then
begin
if CompareText(UpperCase(ExtractFileName(Pn.szExeFile)), 'EXPLORER.EXE') = 0 then //Grandfather process is Explorer.exe
begin
ShowMessage('Debugger detected! Doggone it all!');
Break;
end;
end;

Found := Process32Next(sHandle, Pn); //Find next
end;
end;
end;
finally
CloseHandle(sHandle);
end;
end;

相关阅读 >>

Delphi中messagebox的用法

Delphi中怎样得到系统当前“输入法”名称?

Delphi sqlite 简明上手指南

Delphi获取u盘序列号的代码

Delphi 主程序与dll之间的全局变量问题

Delphi中窗体的事件

Delphi气泡提示

Delphi sccoloredid,星际争霸彩色 id 修改器 v0.2.0,支持 windows vista

Delphi自动检测u盘插入、拔出及获取u盘盘符

Delphi xe5 android实现繁体字到简体字的转换函数

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



打赏

取消

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

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

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

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

评论

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