Compartilhar via


OleSaveToStream

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

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 in which the object is to be saved.

Return Values

The following table shows the HRESULT values that can be returned by this function.

Value Description
S_OK The object was successfully 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 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:

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

OS Versions: Windows CE 3.0 and later.
Header: Ole2.h.
Link Library: Ole32.lib.

See Also

IPersistStream:IPersist | IStream | WriteClassStm | IPersistStream::Save | WriteClassStm | OleLoadFromStream | Determining Supported COM APIs

Last updated on Wednesday, April 13, 2005

© 2005 Microsoft Corporation. All rights reserved.