The IPersistStreamInit::GetSizeMax method returns the size needed to save an object. You can call this method to determine the size and set the necessary buffers before calling the IPersistStreamInit::Save method.
HRESULT GetSizeMax(
ULARGE_INTEGER *pcbSize// out
);
<pipeline.h>
<pipecomp.h>
The method returns an HRESULT value.