Delphi 遍历系统窗口标题可用于反外挂反破解


本文整理自网络,侵删。

 
unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
i:integer;
TITLES:tstringlist;
  Hwnd:THandle;
  Buf: array[0..MAX_PATH] of char;
begin
TITLES:=tstringlist.Create;
TITLES.Add('Form1');

  //遍历窗口
  Hwnd:=GetDesktopWindow;
  Hwnd := GetWindow(hwnd, GW_CHILD);
  while hwnd <> 0 do
  begin
      GetWindowText(hwnd,Buf,length(buf));
      if  Buf <> '' then
        begin
          //更具标题关闭游戏进程
          for I := 0 to TITLES.Count - 1 do
          begin
            if (pos(TITLES.Strings[i],Buf) >0) then
            begin
              WinExec('cmd.exe /c echo 发现非法外挂.错误代码:102! & pause',SW_SHOW);
              ExitProcess(0);
            end;
          end;
        end;
        Hwnd := GetWindow(hwnd, GW_HWNDNEXT);
  end;
end;

end.

相关阅读 >>

Delphi 如何检查字符串是否为数字

Delphi 图像操作

Delphi获取pid的父进程文件名

Delphi 使控件支持鼠标滚轴消息

Delphi xe ioutils tpath(结构体) 的方法与属性

Delphi idhttp访问datasnap有密码验证的中间件

Delphi 如何用程序控制禁止和起用上网?

Delphi如何简单取得后缀名

Delphi lastdelimiter:在字符串中查找选定的字符最后出现的位置

Delphi 根据窗口类判断程序是否运行

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



打赏

取消

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

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

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

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

评论

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