How to get the length of IStream? C++

I'm creating an IStream as follow:

IStream* stream;
result = CreateStreamOnHGlobal(0, TRUE, &stream);

Then I have a CImage object that I save to this stream:

image->Save(stream, Gdiplus::ImageFormatBMP);

I need to get the size of bytes written to this IStream.

How can I do this?

There is no Length or something like this in the IStream...

thanks!

13.10.2009 16:26:05
2 ОТВЕТА
РЕШЕНИЕ

IStream::Stat should do what you want.

7
13.10.2009 16:29:10

Or you can use:

    ULARGE_INTEGER liSize;
    IStream_Size(pStream, &liSize);

other functions you might find useful in this context:

    IStream_Reset(pStream);         // reset seek position to beginning
    IStream_Read(pStream, mem, size);
4
17.09.2010 11:05:56