1、显示所有窗口的标题

2、根据关键字查询窗口

3、某一窗口内的所有控件及其内容

.

unit Unit1;interfaceusesWinapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,System.Classes, Vcl.Graphics,Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;typeTForm1 = class(TForm)Button1: TButton;Memo1: TMemo;Button2: TButton;Button3: TButton;procedure Button1Click(Sender: TObject);procedure Button2Click(Sender: TObject);procedure Button3Click(Sender: TObject);private{ Private declarations }procedure get_actrlh(h: hwnd);public{ Public declarations }end;varForm1: TForm1;hi: integer;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
varszText: array [0 .. 254] of char;hCurrentWindow: hwnd;
beginmemo1.Clear;hCurrentWindow := GetWindow(Handle, GW_HWNDFIRST);while hCurrentWindow <> 0 dobeginif GetWindowText(hCurrentWindow, @szText, 255) > 0 thenMemo1.lines.Add(szText);hCurrentWindow := GetWindow(hCurrentWindow, GW_HWNDNEXT);end;end;procedure TForm1.Button2Click(Sender: TObject);
varszText: array [0 .. 254] of char;hCurrentWindow: hwnd;
beginmemo1.Clear;hCurrentWindow := GetWindow(Handle, GW_HWNDFIRST);while hCurrentWindow <> 0 dobeginif GetWindowText(hCurrentWindow, @szText, 255) > 0 thenif pos('360', szText) <> 0 then // 这里指定某一窗口,可能有多个Memo1.lines.Add(szText);hCurrentWindow := GetWindow(hCurrentWindow, GW_HWNDNEXT);end;end;procedure TForm1.Button3Click(Sender: TObject);
varszText: array [0 .. 254] of char;hCurrentWindow: hwnd;
beginmemo1.Clear;hCurrentWindow := GetWindow(Handle, GW_HWNDFIRST);while hCurrentWindow <> 0 dobeginif GetWindowText(hCurrentWindow, @szText, 255) > 0 thenif pos('360安全浏览器', szText) <> 0 then // 这里指定某一窗口,可能有多个beginMemo1.lines.Add(szText);hi := 0;get_actrlh(hCurrentWindow); // 获取窗口中的所有控件end;hCurrentWindow := GetWindow(hCurrentWindow, GW_HWNDNEXT);end;
end;function gettext(h: hwnd): string;
varname: string;txtlen: integer;begintxtlen := sendmessage(h, wm_gettextlength, 0, 0) + 1;setlength(name, txtlen);sendmessage(h, wm_gettext, txtlen, LongInt(@name[1]));result := name;
end;procedure TForm1.get_actrlh(h: hwnd);
vars: Array [0 .. 255] of char;
beginh := GetWindow(h, GW_child);while h > 0 dobeginGetClassName(h, s, 256);beginMemo1.lines.Add(inttostr(hi) + ':' + s + ':' + trim(gettext(h)));end;hi := hi + 1;get_actrlh(h);h := GetWindow(h, GW_HWNDNEXT);end;
end;end.

转载于:https://www.cnblogs.com/cuibq/archive/2011/11/16/3801907.html

delphi对窗体的查询(delphi xe2)相关推荐

  1. Delphi与SQL模糊查询(转载)

    1.用变量进行模糊查询   对数据进行模糊查询主要用SQL语句LIKE来实现.该语句放在Where语句的后面,使用标识符"%"."_"."[]&quo ...

  2. delphi 异形窗体

    DELPHI 透明窗体 心血来潮想用delphi做透明窗体,要知道我虽然搞了N年编程,但什么也没编写成.惭愧的很,以前VCVB之类的光搞懂它们的控件就让我很费劲,没办法不懂英文.还是学DELPHI吧, ...

  3. 在delphi Form窗体的panel 中嵌入 Fmx窗体

    1.创建2个工程,一个是window application ,一个bpl 工程(multi-device Forml),创建方式见: 在delphi Form窗体调用Fmx窗体_zjg076000的 ...

  4. delphi还有人用吗?delphi过时了吗?为什么还有人使用Delphi开发软件?一文说清Delphi的领先一个时代的开发工具DNA

    我正在和一个不太熟悉Delphi的人聊天.他问Delphi到底是什么使很多人继续喜欢它?delphi还有人用吗?delphi过时了吗?为什么还有人使用Delphi开发软件?我以为我会分享我的答案,看看 ...

  5. delphi word_使用MS Word从Delphi代码进行拼写检查-Delphi中的Office Automation

    delphi word 什么是(OLE)自动化? 什么是自动化服务器? 什么是自动化客户端? ( What is (OLE) Automation? What is Automation Server ...

  6. 问题-Delphi编译时提示缺少delphi自己的单元文件

    问题现象:在编译工程是,提示缺少DELPHI自己的很多单元. 问题原因:这可能是因为手动误删除,或是第三方控件安装时误删除DELPHI自己的目录引起的(如果说错了,希望高人指点). 问题处理: 方法一 ...

  7. access窗体中再制作查询窗体_Excel订单管理系统,窗体录入查询,快捷汇总统算,一键不加班...

    Hello大家好,我是帮帮.今天跟大家分享一张Excel订单管理系统,窗体录入查询,快捷汇总统算,一键不加班. 有个好消息!为了方便大家更快的掌握技巧,寻找捷径.请大家点击文章末尾的"了解更 ...

  8. Delphi数据类型ASCⅡ快捷键查询

    保留字 and array as asm begin case class const constructor destructor dispinterface div do donwnto else ...

  9. 在delphi Form窗体调用Fmx窗体

    在delphi 程序开发中Firemonkey技术允许开发人员创建具有快速的本地性能.动画和图像效果,是跨平台的一个利器.可以利用它来自定义图片和动画效果,让我们的应用更漂亮美观.在windows 应 ...

最新文章

  1. Eclipse ADT 21 Preview 10 发布
  2. SpringDataRedis对Redis的数据类型的常用操作API的使用代码举例
  3. Pinterest:Android系统上的视频管理
  4. Swift学习Day01(Object_c 与Swift的相互调用 )
  5. 程序人生:搜索引擎被禁用,你还会写代码吗?
  6. Installing OpenCV 2.3.1 in Ubuntu
  7. STL源码剖析 lower_bound | upper_bound | binary_search
  8. JVM001_类文件结构
  9. C#调用天气查询服务
  10. VALSE学习(二):行人重识别研究进展回顾
  11. windows.h 详解
  12. 2021-01-01
  13. 打游戏用什么蓝牙耳机好?英雄联盟手游推荐蓝牙耳机
  14. jQuery实现下拉菜单[代码+详细讲解+效果图]
  15. 电机驱动芯片效果对比
  16. leetcode 买卖股票的最佳时机含手续费(Java)
  17. 二维彩虹二维码产品功能更新:增加“赞赏”、“重置”功能
  18. Veil-Evasion免杀
  19. 扫地机器人自动回冲工作原理
  20. 树莓派homebridge开机启动和后台运行

热门文章

  1. react中使用构建缓存_通过构建海滩度假胜地网站,了解如何使用React,Contentful和Netlify...
  2. idea打开web项目之后一直闪烁
  3. (C++)变长数组vector的常见用法
  4. Python培训教程分享:Python异常机制
  5. java 获取init参数,Java如何读取servlet init参数?
  6. intellij打开工程在每个java文件上有个红色的无效符的解决办法
  7. iOS FMDB之FMDatabaseQueue(事物与非事物)
  8. redis 代理工具Predixy安装部署
  9. 通过Google挖掘细分市场的一个案例
  10. Django模型层Meta内部类详解