How to get IStream length? C ++

I create an IStream as follows:

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

Then I have a CImage object that I save in this thread:

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

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

How can i do this?

In IStream there is no length or something like that ...

thanks!

+5
source share
2 answers

IStream :: Stat should do what you want.

+6
source

Or you can use:

    ULARGE_INTEGER liSize;
    IStream_Size(pStream, &liSize);

Other features that may be useful in this context:

    IStream_Reset(pStream);         // reset seek position to beginning
    IStream_Read(pStream, mem, size);
+4
source