Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


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

Posted on 2002-04-27
Medium Priority
Last Modified: 2013-11-20
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)
     IDispatch *disp;
     p->item(?,? ,&disp); //How to write the two params ?

Question by:iProgram
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 12

Accepted Solution

migel earned 400 total points
ID: 6973238
try this
p->item(_variant_t((int)0), _variant_t((int)0),...)
here is MSDN cite:
    VARIANT name,
    VARIANT index,
    IDispatch **pdisp


[in] VARIANT of type VT_I4 or VT_BSTR that specifies the object or collection to retrieve. If this parameter is an integer, it is the zero-based index of the object. If this parameter is a string, all objects with matching name or id properties are retrieved, and a collection is returned if more than one match is made.
[in] VARIANT of type VT_I4 that specifies the zero-based index of the object to retrieve when a collection is returned.
[out, retval] Address of a pointer that receives an IDispatch interface for the object or collection if successful, or NULL otherwise.

Author Comment

ID: 6974393
Ok, it works, thank you:

     CComQIPtr<IHTMLDocument2> spBody(pdispBody);
     IHTMLElementCollection* p;
     if (spBody != NULL)
     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;


Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question