TCHAR HostName[300];
USES_CONVERSION;
CComPtr<IDispatch> pDispatch;
CComQIPtr< IHTMLElementCollection > pElementCol;
CComPtr<IHTMLAnchorElement> pLoct;
hr = pIHTMLDocument2->get_links(&pElementCol ); //取得link集合....
if ( FAILED( hr ) ) return; long p=0;
if(SUCCEEDED(pElementCol->get_length(&p)))
if(p!=0)
{
for(long i=0;i<p;i++)
{ CComBSTR String;
_variant_t index=i; if(SUCCEEDED(pElementCol->item( index, index, &pDispatch)))
if(SUCCEEDED(pDispatch->QueryInterface( IID_IHTMLAnchorElement,(void **) &pLoct))) pLoct->get_href(&String);
ZeroMemory(HostName,300);
lstrcpy(HostName,_bstr_t(String)); 
//添加到列表
m_LinksList.InsertItem(i,HostName);
m_LinksList.SetCheck(i,TRUE); }
}网上流传最广的网页连接提取代码,我试了,获得第1个地址后
if(SUCCEEDED(pElementCol->item( index, index, &pDispatch)))这句就出错了,也就是执行了1次,什么道理?