IOleCache::SetData method

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

pformatetc [in]

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

pmedium [in]

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

fRelease [in]

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 codeDescription
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

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

OleIdl.h

IDL

OleIdl.Idl

IID

IID_IOleCache is defined as 0000011e-0000-0000-C000-000000000046

See also

IOleCache
IOleCache::Cache
IOleCache::SetData

 

 

Community Additions

ADD
Show:
© 2014 Microsoft