EnumWindows

EnumWindows

代码
function EnumWindowsFunc(Handle: THandle; List: TStrings):boolean; stdcall;
var
caption:
array[0..256] of Char;
begin
if GetWindowText(Handle, Caption, SizeOf(Caption)-1) <> 0 then
begin
List.Add(Caption) ;
//List.Add(IntToStr(Handle));
end;
result :
=True;
end;

procedure TMainForm.Button1Click(Sender: TObject);
begin
Memo1.Clear;
ListBox1.Clear;
EnumWindows(@EnumWindowsFunc, LParam(Memo1.Lines));
EnumWindows(@EnumWindowsFunc, LParam(ListBox1.Items));
end;

原文地址:https://www.cnblogs.com/Jekhn/p/1917230.html