Load

HRESULT Load(
IStream *pStream, 
void *pBuffer, 
long cbBuffer);
HRESULT Load(
IPropertyBag *pPropertyBag, 
IErrorLog *pErrorLog, 
void *pBuffer, 
long cbBuffer);

Parameters

pStream

Pointer to IStream from which to load properties.

pBuffer

User-defined buffer. This data is not modified.

cbBuffer

Size of the user buffer. Buffer overwrite is checked using this buffer size.

pPropertyBag

Pointer to IPropertyBag from which to load.

pErrorLog

Pointer to IErrorLog interface. Load errors are sent to the log file.

Return Code

S_OK

Method succeeded.

E_FAIL
Returned if the persisted version is greater or stream IDs differ.

Comments (Load IStream)

Loads properties from the stream. All properties saved to the stream are loaded into memory, but only those properties currently in the collection are set, provided that they were loaded (previously saved). This allows the current collection to contain fewer or more properties than the persisted stream.

Comments (Load PropertyBag)

Loads properties from the PropertyBag. When loading, all properties in the collection are attempted. If a property fails to load, then it is assumed that it was not persisted. Its offset in the user buffer remains unmodified. IsProperSaved will return FALSE for any property not loaded.

If a property is loaded, then the current value of its location in the user buffer is properly freed. Each property is freed according to its data type.

Property type What happens
VT_BOOL Value replaced.
VT_I2 Value replaced.
VT_I4 Value replaced.
VT_R4 Value replaced.
VT_R8 Value replaced.
VT_LPWSTR Current pointer is freed using CoTaskMemFree.
VT_LPSTR Current pointer is freed using CoTaskMemFree.
VT_BSTR Current pointer is freed using SysFreeString.
VT_UNKNOWN Current pointer is freed using IUknown::Release.

Call IsPropSaved to test whether a property was actually saved or loaded.