Solved

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

Posted on 2002-04-27
2
980 Views
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)
          spBody->get_images(&p);
     IDispatch *disp;
     p->item(?,? ,&disp); //How to write the two params ?

0
Comment
Question by:iProgram
2 Comments
 
LVL 12

Accepted Solution

by:
migel earned 100 total points
ID: 6973238
Hi!
try this
p->item(_variant_t((int)0), _variant_t((int)0),...)
here is MSDN cite:
"
HRESULT item(
    VARIANT name,
    VARIANT index,
    IDispatch **pdisp
);

Parameters

name
[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.
index
[in] VARIANT of type VT_I4 that specifies the zero-based index of the object to retrieve when a collection is returned.
pdisp
[out, retval] Address of a pointer that receives an IDispatch interface for the object or collection if successful, or NULL otherwise.
"
0
 
LVL 1

Author Comment

by:iProgram
ID: 6974393
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;


0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Running shell command from Access 3 68
Process filename extension 3 172
twoTwo  challenge 35 93
EvenOdd challenge 10 88
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

911 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now