码迷,mamicode.com
首页 > Web开发 > 详细

vc通过webbrowser操作ie元素

时间:2016-06-08 18:56:41      阅读:486      评论:0      收藏:0      [点我收藏+]

标签:

 

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"));  
        }  
    }  

 

vc通过webbrowser操作ie元素

标签:

原文地址:http://www.cnblogs.com/guohu/p/5571126.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!