Finding the size of a stream (LPSTREAM)

Hello all!

I hope you can help with, what I hope, is a simple question!

I have the following code:

OpenStreamOnFile (MAPIAllocateBuffer, MAPIFreeBuffer, STGM_READ, (LPTSTR)text_file[i].c_str(), NULL,&lpData);

Later on, I need to write lpData to somewhere else, but in order to do this, I need the size. I tried using :

1
2
STATSTG StatInfo;
lpData->Stat(&StatInfo, STATFLAG_NONAME);


Which did give me the size but in a ULARGE_INTEGER, when all I need is a ULONG. I cant figure out a good way to cast a 64 bit integer into a 32 bit long! Is there a better way?

Thanks very much in advance!

Darren
Last edited on
A ULARGE_INTEGER is a union-struct. You can just access the LowPart field for the 32-bit value. (Make sure the HighPart is zero!)

1
2
unsigned long filelength = StatInfo.cbSize.LowPart;
if (StatInfo.cbSize.HighPart != 0) fooey();
Thank you that worked perfect!
Topic archived. No new replies allowed.