Hello! There is the function GetLinksFromPage. She have created a links array, then I wanna pass that array to COM-object (only URLs), thus I have to convert CAtlArray< CComPtr< IDispatch> > to CComSafeArray< BSTR>. How I can do it ?
HRESULT myclass::GetLinksFromPage( const CComPtr<IHTMLDocument2>& pDoc, CAtlArray<CComPtr<IDispatch> > &arrLinks)
{
HRESULT hr = E_FAIL;
{
CComPtr<IHTMLElementCollection> coll;
hr = pDoc->get_links(&coll);
if (SUCCEEDED(hr)&&coll)
{
long length;
hr = coll->get_length(&length);
if (SUCCEEDED(hr))
{
if (length)
{
CComVariant ivar;
for (ivar.vt = VT_I4, ivar.intVal = 0; ivar.intVal<length; ivar.intVal++)
{
CComPtr<IDispatch> p_disp_ins;
hr = coll->item(ivar,ivar,&p_disp_ins);
if (SUCCEEDED(hr))
{
CComQIPtr<IHTMLElement> pCurLink(p_disp_ins);
if (pCurLink)
{
CComBSTR bsHRef;
bsHRef = GetTagAttribute(_T("href"), pCurLink, CComBSTR(_T("about:blank")));
if (bsHRef != _T("about:blank"))
{
if ( isValidLink( bsHRef ) )
{
arrLinks.Add(p_disp_ins);
}
}
}
}
}
}
}
}
}
return hr;
}