void vmsFlashHelper::SaveFlashMovies_noframes(IHTMLDocument2Ptr spDoc, LPCSTR pszFolder) { USES_CONVERSION; if (spDoc == NULL) return; IHTMLElementCollectionPtr spAll; HRESULT hr = spDoc->get_all(&spAll); if (SUCCEEDED(hr) && spAll != NULL) { CComVariant vTagName ("OBJECT"); IDispatchPtr spTagsDisp; hr = spAll->tags (vTagName, &spTagsDisp); if (SUCCEEDED(hr) && spTagsDisp != NULL) { IHTMLElementCollectionPtr spTags (spTagsDisp); if (spTags) { long nCnt; hr = spTags->get_length(&nCnt); if (SUCCEEDED(hr)) { for (long i = 0; i < nCnt; i++) { CComVariant varIdx; V_VT(&varIdx) = VT_I4; V_I4(&varIdx) = i; IDispatchPtr spTagDisp; hr = spTags->item(varIdx, varIdx, &spTagDisp); if (SUCCEEDED(hr) && spTagDisp != NULL) { IHTMLObjectElementPtr spObject(spTagDisp); if (spObject != NULL) { BSTR bstrClassID = NULL; hr = spObject->get_classid(&bstrClassID); if (SUCCEEDED(hr) && bstrClassID) { fsString strClassID = W2A (bstrClassID); SysFreeString (bstrClassID); if (lstrcmpi (strClassID, "CLSID:D27CDB6E-AE6D-11CF-96B8-444553540000") == 0) { IDispatchPtr spObj; spObject->get_object (&spObj); IShockwaveFlashPtr spFlash (spObj); if (spFlash != NULL) { BSTR bstr; spFlash->get_Movie (&bstr); SysFreeString (bstr); } } } } } } } } } } CComVariant vTagName ("EMBED"); IDispatchPtr spTagsDisp; hr = spAll->tags(vTagName, &spTagsDisp); if (SUCCEEDED(hr) && spTagsDisp != NULL) { IHTMLElementCollectionPtr spTags(spTagsDisp); if (spTags != NULL) { long nCnt; hr = spTags->get_length(&nCnt); if (SUCCEEDED(hr)) { for (long i = 0; i < nCnt; i++) { CComVariant varIdx; V_VT(&varIdx) = VT_I4; V_I4(&varIdx) = i; IDispatchPtr spTagDisp; hr = spTags->item(varIdx, varIdx, &spTagDisp); if (SUCCEEDED(hr) && spTagDisp != NULL) { IHTMLEmbedElementPtr spObject(spTagDisp); if (spObject != NULL) { IShockwaveFlashPtr spFlash (spObject); if (spFlash != NULL) { BSTR bstrSrc = NULL; hr = spObject->get_src(&bstrSrc); if (SUCCEEDED(hr) && bstrSrc) { SysFreeString (bstrSrc); } } } } } } } } }
bool CPhotoManager::GetElements(IHTMLDocument2Ptr spDoc) { m_ElementList.clear(); if (spDoc == NULL) return false; CComPtr<IHTMLElementCollection> spAll; HRESULT hr = spDoc->get_all(&spAll); if (FAILED(hr) || !spAll) return false; // Find all the IMG tags in the document CComPtr<IDispatch> spTagsDisp; hr = spAll->tags(CComVariant(CComBSTR("img")), &spTagsDisp); if (FAILED(hr) || !spTagsDisp) return false; CComQIPtr<IHTMLElementCollection> spTags(spTagsDisp); if (!spTags) return false; long nTags = 0; hr = spTags->get_length(&nTags); if (FAILED(hr)) return false; bool bSuccess = false; for (long i=0; i < nTags; i++) { CComPtr<IDispatch> spTagDisp; hr = spTags->item(CComVariant(i), CComVariant(i), &spTagDisp); if (FAILED(hr) || !spTagDisp) continue; CComQIPtr<IHTMLImgElement> spObject(spTagDisp); if (!spObject) continue; CComBSTR bstrFileName; hr = spObject->get_src(&bstrFileName); if (FAILED(hr)) continue; CString strFileName = bstrFileName; if (strFileName.IsEmpty()) continue; strFileName.MakeLower(); bool bPhoto = (strFileName.Find("photo.gif") >= 0); bool bCid = (strFileName.Find("cid:") >= 0); if (!bPhoto && !bCid) continue; PMElementInfo ElemInfo; ElemInfo.pTagDisp= spTagDisp; m_ElementList.push_back(ElemInfo); bSuccess = true; } return bSuccess; }