Share via


OleSaveToStream

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

This function saves an object with the IPersistStream:IPersist interface on it to the specified stream.

Syntax

WINOLEAPI OleSaveToStream(
  IPersistStream* pPStm,
  IStream* pStm 
);

Parameters

  • pPStm
    [in] Pointer to the IPersistStream interface on the object to be saved to the stream.

    The pPStm parameter cannot be NULL.

  • pStm
    [in] Pointer to the IStream interface on the stream that the object is to be saved in.

Return Value

The following HRESULT values can be returned.

Value Description

S_OK

The object was saved.

OLE_E_BLANK

The pPStm parameter is NULL.

STG_E_MEDIUMFULL

There is no space left on device to save the object.

This function can also return any error value 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:

  • Calls the IPersistStream::GetClassID method to get the object's CLSID.
  • Writes the CLSID to the stream with the WriteClassStm function.
  • Calls the IPersistStream::Save method with fClearDirty set to TRUE, which clears the dirty bit in the object.

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

To determine whether the platform supports this function, see Determining Supported COM APIs.

Requirements

Header ole2.h
Library ole32.lib
Windows Embedded CE Windows CE 3.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also

Reference

Automation Functions
IPersistStream
IStream
WriteClassStm
IPersistStream::Save
WriteClassStm
OleLoadFromStream

Concepts

Determining Supported COM APIs