我想请问一下有没有api函数可以获得网页的title?

解决方案 »

  1.   

    直接的API是没有的。但是可以用间接的方法。麻烦点
      

  2.   

    用COM接口可以获得var
      ShellWindow: IShellWindows;
      vi: OleVariant;
      spDisp: IDispatch;
      IDoc1: IHTMLDocument2;
      i: integer;
      nCount: integer;
      IE1: IWebBrowser2;
    begin
      ShellWindow := CoShellWindows.Create;
      nCount := ShellWindow.Count;
      for i := 0 to nCount-1 do
      begin
        vi := i;
        spDisp := ShellWindow.Item(vi);
        spDisp.QueryInterface( iWebBrowser2, IE1);
        if IE1 <> nil then
        begin
          memo1.Lines.Add(inttostr(IE1.Height)+','+inttostr(IE1.Width));
          Memo1.lines.Add(IE1.LocationURL);
          IE1.Document.QueryInterface(IHTMLDocument2,iDoc1);
          if iDoc1 <> nil then
          begin
            memo1.Lines.Add(IDoc1.title);
          end;
        end;
      end;
    end;这个可以得到当前系统中所有IE窗口的属性
    包括当前访问网页的URL,TITLE,还有IE窗口的大小~~你看是你需要的吗?
      

  3.   

    忘了告诉你,要引用的单元uses  ShDocVw, MSHTML;