🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.web
Article #1536

Re: Difference XP SP1 SP1a SP2 ??

#1536
From: Remy Lebeau (TeamB)
Date: Fri, 27 Aug 2004 19:33
70 lines
2883 bytes
"Michael Krug" <michael.krug*nospam*@utanet.at> wrote in message
news:412f2147$1@newsgroups.borland.com...

>     TMemoryStream* pMemStream=new TMemoryStream();
>    if(pMemStream && pCppWebBrowser)

The 'new' operator throws an exception if it fails.  You don't need to check
for a NULL pointer being returned because one won't be returned in the first
place.

>      IPersistStreamInit* pPSI;
>      IHTMLDocument2 *htm;

You should initialize your pointers to NULL.

>      pMemStream->Seek(0, 0);

There is no need to seek an empty stream.

>      if(!pCppWebBrowser->Document)
>      {
>        while(!pCppWebBrowser->Document)
>          Application->ProcessMessages();
>      }

You should be testing the ReadyState property instead.  The Document
property can contain a non-NULL value before the document is actually ready
to be used.

>
if(SUCCEEDED(pCppWebBrowser->Document->QueryInterface(IID_IHTMLDocument2,(LP
VOID*)&htm))
> && (bool(htm))){

Why are you converting the interface pointer to a bool?  You should not be
doing that.

Try this code instead:

    #include <utilcls.h>
    #include <memory>

    if( pCppWebBrowser )
    {
        while( pCppWebBrowser->ReadyState != READYSTATE_COMPLETE )
            Application->ProcessMessages();

        TComInterface<IHTMLDocument2> htm;
        pCppWebBrowser->Document->QueryInterface(IID_IHTMLDocument2,
(LPVOID*)&htm);
        if( htm )
        {
            TComInterface<IPersistStreamInit> pPSI;
            htm->QueryInterface(IID_IPersistStreamInit, (LPVOID*)&pPSI);
            if( pPSI )
            {
                std::auto_ptr<TMemoryStream> MemStream(new TMemoryStream);
                std::auto_ptr<TStreamAdapter> StreamAdapter(new
TStreamAdapter(MemStream.get(), soReference));
                if( SUCCEEDED(pPSI->Save(*pStreamAdapter, FALSE)) )
                {
                    // use pMemStream as needed...
                }
            }
        }
    }


Gambit
Technical Details
Message-ID: <412f8dbc@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <412f2147$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: feeec,83a74329cabca986
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: <412f2147$1@newsgroups.borland.com>
Subject: Re: Difference XP SP1 SP1a SP2 ??
Date: Fri, 27 Aug 2004 12:33:23 -0700
Lines: 72
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: <412f8dbc@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1093635516 68.69.17.41 (27 Aug 2004 12:38:36 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail