IOleCache::SetData method (oleidl.h)

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

Syntax

HRESULT SetData(
  [in] FORMATETC *pformatetc,
  [in] STGMEDIUM *pmedium,
  [in] BOOL      fRelease
);

Parameters

[in] pformatetc

A pointer to a FORMATETC structure that specifies the format of the presentation data being placed in the cache.

[in] pmedium

A pointer to a STGMEDIUM structure that specifies the storage medium that contains the presentation data.

[in] fRelease

Indicates the 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 value

This method returns S_OK on success. Other possible return values include the following.

Return code Description
DV_E_LINDEX
The value is not valid for pformatetc->lindex. Currently, only -1 is supported.
DV_E_FORMATETC
The FORMATETC 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
There is an 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::InitCache 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.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header oleidl.h

See also

IOleCache

IOleCache::Cache

IOleCache::SetData