1>需要引用 webbrowser2.h,mshtml.h

    //m_web绑定的webbrowser的变量
    CComQIPtr<IHTMLDocument2,&IID_IHTMLDocument2> d=m_web.GetDocument();  
    CComPtr<IHTMLElementCollection> c;  
    d->get_all(&c);  
	long len;  
    c->get_length(&len);  
    for(int i=0;i<len;i++){  		
        IDispatch *p;  
        c->item(CComVariant(i),CComVariant(i),&p);  
        CComQIPtr<IHTMLElement,&IID_IHTMLElement> e=p;  
        CComBSTR id;  
        e->get_id(&id);  
		//"txtName"要赋值的元素的id
        if(id==L"txtName"){  
            CComQIPtr<IHTMLInputTextElement,&IID_IHTMLInputTextElement> kw=e;  
            kw->put_value(CComBSTR("asdsa"));  
        }  
    }  

 程序员的基础教程:菜鸟程序员

posted on 2016-06-08 18:26  itprobie-菜鸟程序员  阅读(1625)  评论(1编辑  收藏  举报