FindWindowXG
测试:

函数代码:
function FindWindowXG(strClass, strTitle: string): THandle;
var
hd: THandle;
arrClass: array[..] of Char;
arrTitle: array[..] of Char;
wClass, wTitle: string;
begin
hd := GetWindow(Application.Handle, GW_HWNDFIRST);
while hd > do
begin
GetClassName(hd, @arrClass[], Length(arrClass));
GetWindowText(hd, @arrTitle[], Length(arrTitle)); wClass := arrClass;
wTitle := arrTitle; strClass := Trim(strClass);
strTitle := Trim(strTitle);
if (Length(strClass) > ) and (Length(strTitle) = ) then
begin
if UpperCase(strClass) = UpperCase(wClass) then
begin
Result := hd;
Exit;
end;
end; if (Length(strClass) = ) and (Length(strTitle) > ) then
begin
if Pos(UpperCase(strTitle), UpperCase(wTitle)) > then
begin
Result := hd;
Exit;
end;
end; if (Length(strClass) > ) and (Length(strTitle) > ) then
begin
if (UpperCase(strClass) = UpperCase(wClass))
and (Pos(UpperCase(strTitle), UpperCase(wTitle)) > ) then
begin
Result := hd;
Exit;
end;
end; hd := GetNextWindow(hd, GW_HWNDNEXT);
end; Result := ;
end;
测试代码:
unit Unit1; interface uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ComCtrls; type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Edit3: TEdit;
procedure Button1Click(Sender: TObject);
procedure Edit1Change(Sender: TObject);
procedure Edit2Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.dfm} function FindWindowXG(strClass, strTitle: string): THandle;
var
hd: THandle;
arrClass: array[..] of Char;
arrTitle: array[..] of Char;
wClass, wTitle: string;
begin
hd := GetWindow(Application.Handle, GW_HWNDFIRST);
while hd > do
begin
GetClassName(hd, @arrClass[], Length(arrClass));
GetWindowText(hd, @arrTitle[], Length(arrTitle)); wClass := arrClass;
wTitle := arrTitle; strClass := Trim(strClass);
strTitle := Trim(strTitle);
if (Length(strClass) > ) and (Length(strTitle) = ) then
begin
if UpperCase(strClass) = UpperCase(wClass) then
begin
Result := hd;
Exit;
end;
end; if (Length(strClass) = ) and (Length(strTitle) > ) then
begin
if Pos(UpperCase(strTitle), UpperCase(wTitle)) > then
begin
Result := hd;
Exit;
end;
end; if (Length(strClass) > ) and (Length(strTitle) > ) then
begin
if (UpperCase(strClass) = UpperCase(wClass))
and (Pos(UpperCase(strTitle), UpperCase(wTitle)) > ) then
begin
Result := hd;
Exit;
end;
end; hd := GetNextWindow(hd, GW_HWNDNEXT);
end; Result := ;
end; procedure TForm1.Button1Click(Sender: TObject);
begin
Edit3.Text := IntToStr(FindWindowXG(Edit1.Text,Edit2.Text));
end; procedure TForm1.Edit1Change(Sender: TObject);
begin
Edit3.Clear
end; procedure TForm1.Edit2Change(Sender: TObject);
begin
Edit3.Clear
end; end.
FindWindowXG的更多相关文章
随机推荐
- 使用anaconda 3安装tensorflow 1.15.0 (win10环境)
0.写在前面 之前其实安装过一次tensorflow,但是由于电脑中毒,重装了系统,把所有的环境全部删除了.之前在博客里转发了一篇别人在win10安装tensorflow的教程,但是版本比较旧了, ...
- css 盒子模型简介
盒子模型 <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <ti ...
- 关于Lab3中对于正则表达式的应用
在这里记录一下关于软件构造课程Lab3中关于正则表达式的应用. 在实验内容中,要求用正则表达式来匹配读入文件的内容,从而取得构建图需要的相关信息. 举个例子,读入的文件(GraphPoetTestFi ...
- JS数据统计表 highcharts.js的运用
参考地址 http://www.runoob.com/highcharts/highcharts-column-basic.html 1.下载JS文件引入,或者用CDN function getCou ...
- wyh的dp入门刷题笔记
0: 靠前感觉之前dp抄题解都是抄的题解,自己从没有真正理解过dp.wyh下了很大决心从头学dp,于是便有了这篇文章. 1.背包 前四讲01背包&多重背包&完全背包(混合背包) :樱花 ...
- GitHub fork 合作开发 - 快速实现版
目录 一 预备条件 二 fork项目 三 将项目clone到本地 四 push代码到自己的仓库 五 通过pull request提交代码 六 通过本地配置upstream来同步更新主repo的内容 七 ...
- Lesson 2 Spare that spider
How much of each year do spiders killing insects? Why, you may wonder, should spiders be our friends ...
- Cadence套件:Capture + Allegro应用笔记
1.在Allegro中导入Netlist时,需要进行封装路径的设定: 在Setup->User Preference的Path->Library下面,设定所需封装文件(psm).焊盘文件( ...
- Jquery制作插件---内容切换
//需求:点击左右导航箭头,实现内容的切换 //代码如下 <!DOCTYPE html> <html lang="en"> <head> < ...
- Oracle修改密码
1. 登陆oracle sqlplus '/as sysdba' 2. 修改密码 ALTER USER 用户名IDENTIFIED BY 要修改的密码 ; 3.解锁 alter user 用户名 ac ...