菜鸟提问:怎么获得当前浏览器的URL?如果有多个浏览器被打开时,有怎样获得随意一个浏览器的URL?

解决方案 »

  1.   

    urlList:TStringList;procedure TMainForm.GetUrlList(var UrlList: TStringList);
    var
      sw:IShellWindows;
      i,count:Integer;
      web:IWebBrowser2;
      str:WideString;
    begin
      UrlList.Clear;
      try sw:=CoShellWindows.Create;
          count:=sw.Count;
      except
          sw:=nil;
          count:=0;
      end;
      if count=0 then exit;
      for i:=0 to count-1 do
      begin
         try web:=sw.Item(i) as IWebBrowser2;
             str:=web.LocationURL;
         except
             str:='';
         end;
         if(Pos('file://',LowerCase(str))=0)and(str<>'')then
            UrlList.Add(str);
      end;
    end;