สร้างโครงการใหม่จัดเรียงปุ่มหนึ่งปุ่มและบันทึกใน Form1 และเขียนรหัสต่อไปนี้ในเหตุการณ์ onClick ของ Button1:
ขั้นตอน tform1.button1click (ผู้ส่ง: tobject);
วาจา
HcurrentWindow: hwnd;
sztext: อาร์เรย์ [0..254] ของถ่าน;
เริ่ม
hcurrentWindow: = getWindow (handle, gw_hwndfirst);
ในขณะที่ hcurrentWindow <> 0 ทำ
เริ่ม
ถ้า getWindowText (hcurrentWindow, @SzText, 255)> 0 แล้ว
memo1.lines.add (strpas (@sztext));
hcurrentWindow: = getWindow (HCurrentWindow, GW_HWNDNEXT);
จบ;
จบ;