IOleCache::SetData  5WU9P5

Initializes the cache with data in a specified format and on a specified medium.

HRESULT SetData(

    FORMATETC * pFormatetc,

//Pointer to the format of the presentation data to be placed in the cache

    STGMEDIUM * pmedium,

//Pointer to the storage medium containing the data to be placed in the cache

    BOOL fRelease

//Ownership of the storage medium after this method is completed

   );

 

 

Parameters

pFormatetc

[in] Pointer to the format of the presentation data being placed in the cache.

pmedium

[in] Pointer to the storage medium that contains the presentation data.

fRelease

[in] Ownership of the storage medium after completion of the method. If fRelease is TRUE, the cache takes ownership, freeing the medium when it is finished using it. When fRelease is FALSE, the caller retains ownership and is responsible for freeing the medium. The cache can only use the storage medium for the duration of the call.

 

Return Values

This method supports the standard return value E_OUTOFMEMORY, as well as the following:

S_OK

The cache was filled.

DV_E_LINDEX

The value is not valid for pFormatetc->lindex. Currently, only -1 is supported.

DV_E_FORMATETC

The FORMATETC8CSQ18 structure is invalid.

DV_E_TYMED

The value is not valid for pFormatetc->tymed.

DV_E_DVASPECT

The value is not valid for pFormatetc->dwAspect.

OLE_E_BLANK

Uninitialized object.

DV_E_TARGETDEVICE

The object is static and pFormatetc->ptd is non-NULL.

STG_E_MEDIUMFULL

The storage medium is full.

 

Remarks

IOleCache::SetData is usually called when an object is created from the Clipboard or through a drag-and-drop operation, and Embed Source data is used to create the object.

IOleCache::SetData and IOleCache::InitCache19BP9UA are very similar. There are two main differences. The first difference is that while IOleCache::InitCache initializes the cache with the presentation format provided by the data object, IOleCache::SetData initializes it with a single format. Second, the IOleCache::SetData method ignores the ADVF_NODATA flag while IOleCache::InitCache obeys this flag.

A container can use this method to maintain a single aspect of an object, such as the icon aspect of the object.

See Also

IDataObject::SetData, IOleCache::Cache, ADVF