vc6写如下代码,想提取网页上的链接 CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> pDoc2;
CComPtr<IHTMLElementCollection> pElementCol;
CComPtr<IHTMLAnchorElement> pLoct; HRESULT hr;
pDoc2=(IHTMLDocument2*)m_Web.GetDocument(); //由控件得到IHTMLDocument2接口指针
if(pDoc2==NULL)
{
MessageBox("IHTMLDocument2接口指针为空!");
return;
}
hr=pDoc2->get_links(&pElementCol); //得到网页上的链接
if(S_OK!=hr)
{
MessageBox("得到网页链接错误!");
return;
}
pDoc2->QueryInterface(IID_IHTMLAnchorElement,(void **) &pLoct); BSTR bstrString;
pLoct->get_href(&bstrString);执行到pLoct->get_href(&bstrString);程序就崩溃,debug看到bstrString显示error:expression cannot be evaluated,
pLoct也是同样的错误请问是怎么回事?
CComPtr<IHTMLElementCollection> pElementCol;
CComPtr<IHTMLAnchorElement> pLoct; HRESULT hr;
pDoc2=(IHTMLDocument2*)m_Web.GetDocument(); //由控件得到IHTMLDocument2接口指针
if(pDoc2==NULL)
{
MessageBox("IHTMLDocument2接口指针为空!");
return;
}
hr=pDoc2->get_links(&pElementCol); //得到网页上的链接
if(S_OK!=hr)
{
MessageBox("得到网页链接错误!");
return;
}
pDoc2->QueryInterface(IID_IHTMLAnchorElement,(void **) &pLoct); BSTR bstrString;
pLoct->get_href(&bstrString);执行到pLoct->get_href(&bstrString);程序就崩溃,debug看到bstrString显示error:expression cannot be evaluated,
pLoct也是同样的错误请问是怎么回事?
解决方案 »
- 求教:MapViewOfFile()函数中,如何得到dwFileOffsetHighdw,FileOffsetLow这两个参数
- PNG按钮
- #include <vector> vs2005
- 高手进!!谢谢
- updatedate的一个问题,解决不了了
- 一出手就是百分,急,向指定另一窗口发送鼠标单击消息失败
- 请推荐:1、学vc的经典书 2、学习编程算法的经典书(印刷版)!!!!!!!!!!!!!!重金酬谢!!
- vc++ 组合框怎么使用 有截图更好
- (提问)水平拖动图标实现
- 大哥,救一下偶吧:“鼠标变成漏斗时窗口不想接收任何消息该怎么办?”
- 自己做了一个类继承于CTabCtrl,对话框中的member variable无法选择这个子类的control
- VC下MSCOMM写的串口程序为什么不能连续接受呢?
http://www.vckbase.com/document/viewdoc/?id=646
怎么从IHTMLDocument2查询IHTMLAnchorElement?我可以保证pLoct的值是空。
for (i=0; i<length; i++)
{
pElementCol->get_Item(i) --> IHTMLElement
IHTMLElement::QueryInterface --> IHTMLAnchorElement
IHTMLAnchorElement::get_href
}