IHTMLAnchorElement中的get_href()是得到url,该如何得到url对应的链接文字呢? 谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 BOOL MyDlg::GetAllLinks(CMyHtmlView *pView){ IHTMLDocument2 * pDoc = NULL; IHTMLElementCollection * pAllElem = NULL; IHTMLElement *pElem = NULL; IHTMLAnchorElement * pAnchor = NULL; IHTMLElement* ptext; long p; BSTR bstrSrc; VARIANT name; name.vt = VT_I4; try{ pDoc = (IHTMLDocument2*)(pView->GetHtmlDocument()); if(pDoc!=NULL) { pDoc->get_links(&pAllElem); if(pAllElem!=NULL) { pAllElem->get_length(&p); if(p>0) { for(int i=0; i<p; i++) { name.lVal = i; if(pAllElem->item(name, name, (LPDISPATCH*)&pElem)==S_OK) { if(pElem != NULL) { pElem->QueryInterface(&pAnchor); if(pAnchor!=NULL) { pAnchor->get_href(&bstrSrc); CString sHref(bstrSrc); //url SysFreeString(bstrSrc); pAnchor->QueryInterface(&ptext); ptext->get_innerText(&bstrSrc); CString sText(bstrSrc); //text SysFreeString(bstrSrc); ptext->Release(); pAnchor->Release(); pAnchor = NULL; } pElem->Release(); pElem = NULL; } } } } } } }catch(...){} try{ if(pDoc != NULL) pDoc->Release(); if(pAllElem != NULL) pAllElem->Release(); }catch(...){} return TRUE;} 基于dialog的控件排列、放大、缩小? 抠图问题 小球碰撞游戏程序代码,求注释,越详细越好》》》 CRichEdit中的字符数问题 如何自绘ComboBox的那个ListBox 包括其滚动条? SetBitmapBits显示位图出现怪问题 键盘钩子问题,请各位高手指教 如何把字符串转换为2进制,字符串中存的是十进制字符,'0'-'9' 关于辐射度 大虾们。。求教了。。。 如何使按钮在不同的状态下显示不同的提示信息 初学的一个问题
{
IHTMLDocument2 * pDoc = NULL;
IHTMLElementCollection * pAllElem = NULL;
IHTMLElement *pElem = NULL;
IHTMLAnchorElement * pAnchor = NULL;
IHTMLElement* ptext;
long p;
BSTR bstrSrc;
VARIANT name;
name.vt = VT_I4;
try{
pDoc = (IHTMLDocument2*)(pView->GetHtmlDocument());
if(pDoc!=NULL)
{
pDoc->get_links(&pAllElem);
if(pAllElem!=NULL)
{
pAllElem->get_length(&p);
if(p>0)
{
for(int i=0; i<p; i++)
{
name.lVal = i;
if(pAllElem->item(name, name, (LPDISPATCH*)&pElem)==S_OK)
{
if(pElem != NULL)
{
pElem->QueryInterface(&pAnchor);
if(pAnchor!=NULL)
{
pAnchor->get_href(&bstrSrc);
CString sHref(bstrSrc); //url
SysFreeString(bstrSrc);
pAnchor->QueryInterface(&ptext);
ptext->get_innerText(&bstrSrc);
CString sText(bstrSrc); //text
SysFreeString(bstrSrc);
ptext->Release();
pAnchor->Release();
pAnchor = NULL;
}
pElem->Release();
pElem = NULL;
}
}
}
}
}
}
}catch(...){}
try{
if(pDoc != NULL)
pDoc->Release();
if(pAllElem != NULL)
pAllElem->Release();
}catch(...){}
return TRUE;
}