var
  i, count: Integer;
  e: IHTMLElement;
begin
  count := (WebBrowser1.Document as IHTMLDocument2).all.length;
  for i := 1 to count do
  begin
    e := ((WebBrowser1.Document as IHTMLDocument2).all.item(EmptyParam, i) as IHTMLElement;
    ShowMessage(e.outerHTML);
  end;
end;我每次得到的都是.all的第一个item,没法列举?

解决方案 »

  1.   

    XP系统,
    system32下的mshtml.dll是 2004年8月7日, 8:00:00
    版本 6.0.2900.2180
      

  2.   

    //i, EmptyParam参数位置交换
    var
      i, count: Integer;
      e: IHTMLElement;
    begin
      count := (WebBrowser1.Document as IHTMLDocument2).all.length;
      for i := 0 to count - 1 do //下标从0开始
      begin
        e := (WebBrowser1.Document as IHTMLDocument2).all.item(i, EmptyParam) as IHTMLElement;
        ShowMessage(e.outerHTML);
      end;
    end;
      

  3.   

    thanks.真是,Delphi7的接口单元里的声明是
    function  item(name: OleVariant; index: OleVariant): IDispatch; safecall;我用name能访问任意有名字的item,
    没想到用下标访问也要使用第一个参数。