以下代码供参考:
function EnumChildWindowsProc(H: HWnd; TF: TMainform): Boolean; stdcall;//回调函数
var
Buffer: array[0..255] of Char;
begin
Result := True; //返回True才会继续查找下一个
if (GetWindowText(H, Buffer, 255)>0) then//得到窗口的Caption
TF.listbox1.Items.Add(StrPas(Buffer));
end;
procedure TMainForm.ToolButton1Click(Sender: TObject);
begin
EnumChildWindows(Handle, @EnumChildWindowsProc, Longint(Self));
end;