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;} 关于SSDT HOOK VMR9的alphablending问题 怎样用SDK安装字体,注册控件,谢谢大虾 基于对话框的文本编辑器中状态区的实现问题 急,请问怎样动态申请一个数组? 提问,关于数字签名的事情,不明白的说。 网上哪里可有简体电子版的<<深入浅出MFC>>呀? 模板问题。 Visual Studio 2012新建项目就报错 请问各位大侠:怎样按概率产生随机数?? 如何使按钮在不同的状态下显示不同的提示信息 初学的一个问题
{
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;
}