The IPropertyBag2 InterfaceThe IPropertyBag2 Interface*
*



Contents  *



Index  *Topic Contents
*Previous Topic: IPersistPropertyBag2::Save
*Next Topic: IPropertyBag2::CountProperties

The IPropertyBag2 Interface

When a client wants to have exact control over how individually named properties of an object are saved, it will attempt to use an object's IPersistPropertyBag2 interface as a persistence mechanism. In that case, the client supplies a "property bag" to the object in the form of an IPropertyBag2 interface.

IPropertyBag2 is an enhancement of the IPropertyBag interface. IPropertyBag2 allows the object to obtain type information for each property through the use of the CountProperties and GetPropertyInfo methods. A property bag that implements IPropertyBag2 must also support IPropertyBag so that objects that only support IPropertyBag can access their properties. Likewise, an object that supports IPropertyBag2 must also support IPropertyBag so that it can communicate with property bags that only support IPropertyBag.

IDL:

[object, uuid(22F55882-280B-11d0-A8A9-00A0C90C2004), pointer_default(unique)]
interface IPropertyBag2 : IUnknown
{
    typedef [unique]IPropertyBag2 *LPPROPERTYBAG2;

    HRESULT Read(
        [in]	ULONG cProperties,
        [in]	PROPBAG2 * pPropBag,
        [in]  	IErrorLog * pErrLog,
        [out] 	VARIANT * pvarValue,
        [out]   HRESULT * phrError);

    HRESULT Write(
        [in]	ULONG cProperties,
        [in] 	PROPBAG2 * pPropBag,
        [in] 	VARIANT * pvarValue);

    HRESULT CountProperties(
        [out] 	ULONG * pcProperties);

    HRESULT GetPropertyInfo(
        [in]  	ULONG iProperty,
        [in]  	ULONG cProperties,
        [out] 	PROPBAG2 * pPropBag,
        [out] 	ULONG * pcProperties);

    HRESULT LoadObject(
        [in]	LPCOLESTR pstrName,
        [in]	DWORD dwHint,
        [in]	IUnknown * pUnkObject,
        [in]	IErrorLog * pErrLog);
}

When the object wants to read a property in IPersistPropertyBag2::Load, it will call IPropertyBag2::Read. When the object is saving properties in IPersistPropertyBag2::Save, it will call IPropertyBag2::Write.

The client records errors that occur during Read with the supplied IErrorLog interface.

arrowg.gifIPropertyBag2::CountProperties

arrowg.gifIPropertyBag2::GetPropertyInfo

arrowg.gifIPropertyBag2::LoadObject

arrowg.gifIPropertyBag2::Read

arrowg.gifIPropertyBag2::Write

arrowg.gifPROPBAG2

arrowg.gifPROPBAG2_TYPE


Up Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.