在HtmlView中如何改变链接.
如在网页中有二个链接
<a href="aa.htm">aa</a>
<a href="bb.htm">bb</a>
现在我想改变<a href="aa.htm">aa</a>的链接.改成<a href="cc.htm">cc</a>.
请问有什么方法呢?千万别告诉我用查找字符串替换字符串哦.
void CChangeurlView::OnEditChangeurl()
{
// please note that you have to release those interface pointer
IDispatch* spDisp;
spDisp=GetHtmlDocument();
IHTMLDocument2* spDoc;
spDisp->QueryInterface(IID_IHTMLDocument2,(void**)&spDoc);
IHTMLElementCollection* pColl;
spDoc->get_anchors(&pColl);
long num;
HRESULT hr=pColl->get_length(&num);
for(long i=0;i<num;i++)
{
IDispatch* spDisp2;
pColl->item(_variant_t(i),_variant_t(i),&spDisp2);
IHTMLAnchorElement* spAnchor;
spDisp2->QueryInterface(IID_IHTMLAnchorElement,(void**)&spAnchor);
if(spAnchor)
spAnchor->put_href(_bstr_t("http://www.csdn.net"));
}
}