我程序中取到一个IHTMLElement,调用了它的get_children,取到了一个IDispatch **,这个IDispatch **怎么用呢,要用它一定式要调用QueryInterface,查询接口,可是我怎么知道这个IDispatch中能QueryInterface到什么接口呢? MSDN中能查到么 怎么查 谢谢

解决方案 »

  1.   

    MSDN 肯定能查到了,找IHTMLElement相关的
      

  2.   

    Using the Document Interface
    Once you have obtained the document interface, you can use any of the IHTMLDocument2 interfaces to obtain or modify the document's properties. This will most commonly involve getting some of the IHTMLElementCollection interfaces for the different element collections contained in the document.A very common collection is the all collection. The all collection is obtained using the IHTMLDocument2::all method. This method returns an IHTMLElementCollection interface that contains all the elements in the document. You can then enumerate the elements using the IHTMLElementCollection::item method. The IHTMLElementCollection::item method provides you with an IDispatch pointer on which you can call QueryInterface, requesting IID_IHTMLElement. This will give you an IHTMLElement interface pointer that you can use to obtain or set information for the individual element.Most elements provide an interface for working with that specific element. These element-specific interface names take the format of IHTMLXXXXElement, where XXXX is the name of the element. To obtain the element-specific interface, call QueryInterface on the IHTMLElement interface, requesting the element-specific interface that is desired. For example, the img element provides an IHTMLImgElement interface that can be used to work with the img element specifically. For a list of the available element-specific interfaces, see the interface listing in Interfaces and Scripting Objects.
      

  3.   

    用智能指针,定义一下这个接口的智能指针就可以了,然后就可以使用它的方法。
    比如:
    IDispathaaa aaa;
    为aaa赋值;
    aaa->dosomthing();
      

  4.   

    必须查看MSDN,虽然没有明确说明,但是简介里已说明是一个元素集合,所以应该查询IHTMLElementCollection[2|3]接口。