如题?

解决方案 »

  1.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        Memo1: TMemo;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;  function EnumWindowsProc(hwnd: THandle; lParam: LPARAM): boolean; stdcall;var
      Form1: TForm1;implementation{$R *.dfm}function EnumWindowsProc(hwnd: THandle; lParam: LPARAM): boolean; stdcall;
    var
      classname: array[0..255] of char;
      addr: array[0..255] of char;
      edith: THandle;
    begin
      GetClassName(hwnd,classname,256);
      if classname = 'IEFrame' then
      begin
        edith:= findwindowex(hwnd,0,'WorkerW',nil);
        edith:= findwindowex(edith,0,'ReBarWindow32',nil);
        edith:= findwindowex(edith,0,'ComboBoxEx32',nil);
        sendmessage(edith,wm_gettext,256,Integer(@addr));
        Form1.Memo1.Lines.Add(addr);
      end;
      result:= true;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      EnumWindows(@EnumWindowsProc,0);
    end;end.
      

  2.   

    我有点疑惑,这楼上的这种方法,会会有的弹出窗口,就没有地址栏的那种,会取不到?
    因为那些窗口里没有ComboBoxEx32这种类?
      

  3.   

    unit WebListTrd;interfaceuses
      Classes, ShDocVw, SysUtils, ActiveX;type
      TGetWebListThread = class(TThread)
      private
        function  GetWebPointCollection(var nCount: Integer):IShellWindows;
        function  GetWebPageUrl(const shellWindows: IShellWindows; Index: Integer): string;
        procedure CreateWebList(var sltWebList: TStringList);
      protected
        procedure Execute; override;
      public
        sltWebList:TStringList;
        Constructor Create;
      end;implementationconstructor TGetWebListThread.Create;
    begin
      FreeOnTerminate:= True;
      inherited Create(True);
      Resume;
    end;procedure TGetWebListThread.Execute;
    begin
      CreateWebList(sltWebList);
    end;procedure TGetWebListThread.CreateWebList(var sltWebList: TStringList);
    var
      ShellWindows: IShellWindows;
      URL: string;
      I,nCount: integer;
    begin
      //Initializes the COM library
      CoInitialize(nil);  //Clear UrlList
      sltWebList:=TStringList.Create;
      sltWebList.CaseSensitive:=false;
      sltWebList.Clear;  // Try to get all IE windows point
      ShellWindows:=GetWebPointCollection(nCount);  //Try to get url and add it to UrlList
      for I:=0 to nCount-1 do
      begin
        URL:=GetWebPageUrl(ShellWindows,I);
        if URL='' then continue;
        sltWebList.Add(url)
      end;  //Closes the COM library
      CoUnInitialize;
    end;function TGetWebListThread.GetWebPointCollection(var nCount: Integer): IShellWindows;
    begin
      try
        Result:=CoShellWindows.Create;
        nCount:=Result.Count;
      except
        Result:=nil;
        nCount:=0;
      end;
    end;function TGetWebListThread.GetWebPageUrl(const shellWindows: IShellWindows; Index: Integer): string;  function IsUrlValid(URL: String):boolean;
      begin
        result:=(URL<>'')and(Pos('http://',LowerCase(Url))<>0);
      end;var
      WebBrowser:IWebBrowser2;
      url: string;
    begin
      try
        WebBrowser:=shellWindows.Item(index) as IWebBrowser2;
      except
        WebBrowser:=nil;
      end;  if WebBrowser=nil then
        url:=''
      else
        url:=WebBrowser.LocationURL;  if not IsUrlValid(url) then url:='';  Result:=url;
    end;end.