delphi 获取所有窗口标题

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;

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

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.BitBtn1Click(Sender: TObject);
var
H_window:HWND;
Text:array[0..255] of char;
begin
H_window:=GetWindow(Handle,GW_HWNDFIRST);
While H_window<>0 do
begin
if GETWindowText(H_window,@text,255)>0 then
memo1.Lines.Add(StrPas(@Text));
H_window:=GetWindow(H_Window,GW_HWNDNEXT);
end;
end;

end.

原文地址:https://www.cnblogs.com/blogpro/p/11446765.html