如何取得所有以打开的浏览器窗口(也就是IE了)的所有句柄?

解决方案 »

  1.   

    dd:=findwindow('IEFrame',nil);
    while dd<>0 then
    begin
    dd:=findwindow('IEFrame',nil);end;
      

  2.   

    H:=findwindow('IEFrame',nil);
      while (H<>0) do
      begin
        ShowMessage(IntToStr(H));
        H:=findwindow('IEFrame',nil);
      end;结果死循环了!
      

  3.   

    function EnumIE(Hwnd:HWND;lParam:LPARAM):boolean;stdcall;
    var pBuf:PChar;
    begin
     GetMem(pBuf,200);
     ZeroMemory(pBuf,200);
     GetWindowText(Hwnd,pBuf,200);
     if Pos('Microsoft Internet Explorer',pBuf)>0 then
        Form1.Memo1.Lines.Add(pBuf);
     FreeMem(pBuf);
     Result:=True;
    end;
    procedure TForm1.FormCreate(Sender: TObject);
    begin
        EnumWindows(@EnumIE,0);
    end;
      

  4.   

    uses SHDocVwprocedure TForm1.Button2Click(Sender: TObject);
    var
      x: Integer;
      Sw: IShellWindows;
    begin
      sw := CoShellWindows.Create;
      for x := SW.Count - 1 downto 0 do
      begin
        ListBox1.Items.add(IntToStr(variant(Sw.Item(x)).hwnd));
      end;
    end;