如题!我想得到当前WINDOWS打开的所有窗口!

解决方案 »

  1.   

    用API函数EnumWindows,具体你看看帮助吧,很详细的!
    该函数能列处所有窗体!
      

  2.   

    给你个列子吧!新建个form(name:FormCallBack),一个listbox,一个button
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;
    type
      EnumWindowsProc = function (Hwnd: THandle;
        Param: Pointer): Boolean; stdcall;
    type
      TFormCallBack = class(TForm)
        ListBox1: TListBox;
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      FormCallBack: TFormCallBack;implementation{$R *.dfm}function GetTitle (Hwnd: THandle; Param: Pointer): Boolean; stdcall;
    var
      Text: string;
    begin
      SetLength (Text, 100);
      GetWindowText (Hwnd, PChar (Text), 100);
      FormCallBack.ListBox1.Items.Add (
        IntToStr (Hwnd) + ': ' + Text);
      Result := True;
    end;procedure TFormCallBack.Button1Click(Sender: TObject);
    var
      EWProc: EnumWindowsProc;
    begin
      ListBox1.Items.Clear;
      EWProc := GetTitle;
      EnumWindows (@EWProc, 0);
    end;end.