function EnumWndProc(AWnd: HWND; AlParam: LPARAM): Boolean; stdcall; var szText: array[0..254] of char; begin if IsWindowVisible(awnd) then begin GetWindowText(awnd, @szText, 255); if szText<>'' then Form1.listBox1.Items.Add(strPas(@szText)); end; Result := True; end; procedure TForm1.FormCreate(Sender: TObject); begin EnumWindows(@EnumWndProc, 0); end;
function EnumWndProc(AWnd: HWND; AlParam: LPARAM): Boolean; stdcall; var szText: array[0..254] of char; begin Result := True; if IsWindowVisible(awnd) and (awnd<>Form1.Handle) then //要排除掉本窗口 begin GetWindowText(awnd, @szText, 255); if szText<>'' then begin Form1.listBox1.Items.Add(inttostr(awnd)+': '+strPas(@szText)); Result:=False; end; end;