Link to home
Start Free TrialLog in
Avatar of iProgram
iProgram

asked on

How to save All images and/or one Web page using IHTMLDocument2?

hi experts,
I have already get the IHTMLDocument2:

STDMETHODIMP CHTML2::OnTest(IDispatch *pdispHTMLDoc)
{
     .......
     CComQIPtr<IHTMLDocument2> spBody(pdispHTMLDoc);
     //Now, How to get all images and save them to local folder?
     return S_OK;
}
I tried the following codes below:
     
     IHTMLElementCollection* p;
     if (spBody != NULL)
          spBody->get_images(&p);
     IDispatch *disp;
     p->item(?,? ,&disp); //How to write the two params ?

ASKER CERTIFIED SOLUTION
Avatar of migel
migel

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of iProgram
iProgram

ASKER

Ok, it works, thank you:

     
     CComQIPtr<IHTMLDocument2> spBody(pdispBody);
     IHTMLElementCollection* p;
     if (spBody != NULL)
          spBody->get_images(&p);
     IDispatch *disp;
     long i=0;
     _variant_t va(i, VT_I4);
     p->item(va, va,&disp);
     CComQIPtr<IHTMLImgElement> img(disp);
     BSTR str;
     img->get_src(&str);    //I get it here:)
     ......
     return S_OK;