posts - 710,  comments - 81,  views - 260万
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

 

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//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   itprobie-菜鸟程序员  阅读(1629)  评论(1编辑  收藏  举报
点击右上角即可分享
微信分享提示