Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This method initializes an object from the stream where it was previously saved.

Syntax

HRESULT Load(
  LPSTREAM 
pStm 
);

Parameters

pStm

[in] IStream pointer to the stream from which the object should be loaded.

Return Value

S_OK

The object was successfully loaded.

E_OUTOFMEMORY

The object was not loaded due to a lack of memory.

E_FAIL

The object was not loaded due to some reason other than a lack of memory.

Remarks

This method loads an object from its associated stream. The seek pointer is set as it was in the most recent IPersistStreamInit::Savemethod. This method can seek and read from the stream, but cannot write to it.

On exit, the seek pointer should be left in the same position as it was on exit from Save, immediately past the end of the data.

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

Notes to Callers

Rather than calling IPersistStreamInit::Loaddirectly, you typically call the OleLoadFromStreamfunction, which does the following:

  1. Calls the ReadClassStmfunction to get the class identifier from the stream.

  2. Calls the CoCreateInstancefunction to create an instance of the object.

  3. Queries the instance for IPersistStreamInit.

  4. Calls IPersistStreamInit::Load.

The OleLoadFromStreamfunction assumes that objects are stored in the stream with a class identifier followed by the object data. This storage pattern is used by the generic, composite-moniker implementation provided by OLE.

If the objects are not stored using this pattern, you must call the methods separately yourself.

Notes to Implementers

If the object has already been initialized with InitNew, then this method must return E_UNEXPECTED.

Requirements

Header ocidl.h, ocidl.idl
Library ole32.lib, uuid.lib
Windows Embedded CE Windows CE 3.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also