Article View: borland.public.cppbuilder.internet.web
Article #1185Re: How to save a certain web-adress-contents as .mht (web-archive, single file) as IE does?
From: Remy Lebeau (TeamB)
Date: Mon, 11 Jul 2005 16:57
Date: Mon, 11 Jul 2005 16:57
86 lines
3682 bytes
3682 bytes
<M_R> wrote in message news:8284d11gouq3m4pmis3ocahjqu6fbui7v2@4ax.com...
> I looked around the internet and found some sources for VC, e.g. in
>
> http://www.codeguru.com/Cpp/I-N/ieprogram/comments.php/c4397/?thread=1191
>
> but unfortunately I failed in compiling this with BCB.
That is because that code is not very BCB-friendly.
> #import "c:\programme\gemeinsame dateien\system\ado\msado15.dll"
> no_namespace raw_interfaces_only
> #import "c:\windows\system32\cdosys.dll" no_namespace
> raw_interfaces_only
#import is discouraged in BCB. Use the TLIBIMP.EXE utility to import those
libraries instead.
> #include "c:\language\cppbuilder.5\include\cdosysstr.h"
> #include "c:\language\cppbuilder.5\include\cdosyserr.h"
You should not be specifying full paths for those files. BCB includes those
files in its own Includes folder, so you can do this instead:
#include <cdosysstr.h>
#include <cdosyserr.h>
> and continued with
Your translation is not correct. Use this instead:
#include <cdosysstr.h>
#include <cdosyserr.h>
#include <cdoex.h>
#include <utilcls.h>
CLSID CLSID_Configuration = {0xCD000002, 0x8B95, 0x11D1, {0x82, 0xDB,
0x00, 0xC0, 0x4F, 0xB1, 0x62, 0x5D}};
CLSID CLSID_Message = {0xCD000001, 0x8B95, 0x11D1, {0x82, 0xDB, 0x00,
0xC0, 0x4F, 0xB1, 0x62, 0x5D}};
bool SaveWholePage(const AnsiString &PageURL, const AnsiString
&FileName)
{
bool ret = false;
CoInitialize(NULL);
TComInterface<IMessage> Msg;
TComInterface<IConfiguration> Config;
TComInterface<_Stream> Stream;
if( SUCCEEDED(CoCreateInstance(CLSID_Message, NULL,
CLSCTX_INPROC_SERVER, IID_IMessage, (void**)&Msg)) )
{
if( SUCCEEDED(CoCreateInstance(CLSID_Configuration, NULL,
CLSCTX_INPROC_SERVER, IID_IConfiguration, (void**)&Config)) )
{
Msg->put_Configuration(Config);
if( SUCCEEDED(Msg->CreateMHTMLBody(WideString(PageURL),
cdoSuppressNone, WideString("domain\\username"), WideString("password"))))
{
if( SUCCEEDED(Msg->GetStream(&Stream)) )
ret =
SUCCEEDED(Stream->SaveToFile(WideString(FileName), adSaveCreateOverWrite));
}
}
}
CoUninitialize();
return ret;
}
> Because I got an error saying Message/Configuration is unknown
> I explicitely defined them before the function as
>
> typedef IMessage Message;
> typedef IConfiguration Configuration;
That is not the correct thing to do.
Gambit
Technical Details
Message-ID:
<42d2a51c$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<fslpc1l5nlojp6900rd4q5064do1iankcg@4ax.com> <42cd6702@newsgroups.borland.com> <8284d11gouq3m4pmis3ocahjqu6fbui7v2@4ax.com>Show Full Headers
Complete Article Headers
X-Google-Thread: feeec,97b1fec950ab4a3e X-Google-Attributes: gidfeeec,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.internet.web References: <fslpc1l5nlojp6900rd4q5064do1iankcg@4ax.com> <42cd6702@newsgroups.borland.com> <8284d11gouq3m4pmis3ocahjqu6fbui7v2@4ax.com> Subject: Re: How to save a certain web-adress-contents as .mht (web-archive, single file) as IE does? Date: Mon, 11 Jul 2005 09:57:51 -0700 Lines: 88 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <42d2a51c$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1121101084 68.69.17.41 (11 Jul 2005 09:58:04 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail