Magazine |
| | Community |
| | Workshop |
| | Tools & Samples |
| | Training |
| | Site Info |
|
|
||||||||
|
When a client wants to have exact control over how individually named properties of an object are saved, it would attempt to use an object's IPersistPropertyBag interface as a persistence mechanism. In that case, the client supplies a "property bag" to the object in the form of an IPropertyBag interface.
IDL:
[ uuid(55272A00-42CB-11CE-8135-00AA004BB851) , object, pointer_default(unique) ] interface IPropertyBag : IUnknown { HRESULT Read([in] LPCOLESTR pszPropName, [in,out] VARIANT *pVar , [in,out] IErrorLog *pErrorLog); HRESULT Write([in] LPCOLESTR pszPropName, [in] VARIANT *pVar); };
When the object wishes to read a property in IPersistPropertyBag::Load, it will call IPropertyBag::Read. When the object is saving properties in IPersistPropertyBag::Save, it will call IPropertyBag::Write. Each property is described with a name in pszPropName whose value is exchanged in a VARIANT. This information allows a client to save the property values as text, for instance, which is the primary reason why a client might choose to support IPersistPropertyBag.
The client records errors that occur during Read into the supplied "error log."
IPropertyBag Methods
Read Asks the property bag to read the property named with pszPropName into the caller-initialized VARIANT in pVar Write Asks the property bag to save the property named with pszPropName using the type and value in the caller-initialized VARIANT in pVar.
Does this content meet your programming needs? Write us!
© 1998 Microsoft Corporation. All rights reserved. Terms of use.