OleSaveToStream function (ole2.h)

Saves an object with the IPersistStream interface on it to the specified stream.

Syntax

HRESULT OleSaveToStream(
  [in] LPPERSISTSTREAM pPStm,
  [in] LPSTREAM        pStm
);

Parameters

[in] pPStm

Pointer to the IPersistStream interface on the object to be saved to the stream. The pPStm parameter cannot be NULL.

[in] pStm

Pointer to the IStream interface on the stream in which the object is to be saved.

Return value

This function returns S_OK on success. Other possible values include the following.

Return code Description
STGMEDIUM_E_FULL
The object could not be saved due to lack of disk space.
OLE_E_BLANK
The pPStm parameter is NULL.
 

This function can also return any of the error values returned by the WriteClassStm function or the IPersistStream::Save method.

Remarks

This function simplifies saving an object that implements the IPersistStream interface to a stream. In this stream, the object's CLSID precedes its data. When the stream is retrieved, the CLSID permits the proper code to be associated with the data. The OleSaveToStream function does the following:

The companion helper, OleLoadFromStream, loads objects saved in this way.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header ole2.h (include Ole2.h)
Library Ole32.lib
DLL Ole32.dll
API set ext-ms-win-com-ole32-l1-1-1 (introduced in Windows 8.1)

See also

IPersistStream

IStream

OleLoadFromStream