导航

<2005年1月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
303112345

随笔分类

随笔档案

文章档案

相册

2005年1月6日

对于分贞的HTML,IHTMLDocument2->get_frames()函数得到的IDispatch指针到底是什么?

IHTMLDocument2  *pDoc=NULL;
pDoc=(IHTMLDocument2 *)GetHtmlDocument();    //这个是CHtmlView
                                             //IWebBrowser2使用get_Document();
IHTMLFramesCollection2 *pCol=NULL;
HRESULT hr=pDoc->get_frames(&pCol);       //取得分贞的frame数组
ASSERT(SUCCEEDED(hr));

VARIANT vFrame,vIndex;
vIndex.vt=VT_I4;    vIndex.lVal=0;          //准备取得第0号贞
hr=pCol->get_item(&vIndex,&vFrame);
ASSERT(SUCCEEDED(hr));

        //取得的这个接口指针,其实是IHTMLWindow2的接口指针。
IHTMLWindow2 *pWin=(IHTMLWindow2 *)vFrame.pdispVal;
IHTMLDocument2 *pDoc2=NULL;
hr=pWin->get_document(&pDoc2);
ASSERT(SUCCEEDED(hr));

BSTR bstr=NULL;
hr=pDoc2->get_URL(&bstr);                  //举例,比如取得URL
ASSERT(SUCCEEDED(hr))

SysFreeString(bstr);
pDoc2->Release();
pWin->Release();
pCol->Release();
pDoc->Release();
发表于 2005-01-06 13:39 杨老师的茅屋 阅读(1691) | 评论 (1)编辑 收藏

统计