最好能给我一个例子,谢啦

解决方案 »

  1.   

    var
    Form1: TForm1;
     Wnd: HWND;
    implementation{$R *.DFM}Function EnumWindowsProc (Wnd: HWND; lb: TListbox): BOOL; stdcall;
    var
    caption: Array [0..128] of Char;
    begin
    Result := True;
    if { skip invisible windows }
       IsWindowVisible(Wnd) and
       { only process truly top-level windows. GetWindowLong must be used, not
    GetParent }
       ((GetWindowLong(Wnd, GWL_HWNDPARENT) = 0) or
        (HWND(GetWindowLong(Wnd, GWL_HWNDPARENT)) = GetDesktopWindow)) and
       { skip WS_EX_TOOLWINDOW windows }
       ((GetWindowLong(Wnd, GWL_EXSTYLE) and WS_EX_TOOLWINDOW) = 0)
    then begin
      SendMessage( Wnd, WM_GETTEXT, Sizeof( caption ), integer(@caption));
      lb.Items.AddObject( caption, TObject( Wnd ));
    end;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
    listbox1.clear;
    EnumWindows( @EnumWindowsProc, integer( listbox1 ));
    end;