Share via


IDataObject::GetData

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

This method is called by a data consumer to obtain data from a source data object. The GetData method renders the data described in the specified FORMATETC structure and transfers it through the specified STGMEDIUM structure. The caller then assumes responsibility for releasing the STGMEDIUM structure.

Syntax

HRESULT GetData(
  FORMATETC* pFormatetc,
  STGMEDIUM* pmedium
);

Parameters

  • pFormatetc
    [in] Pointer to the FORMATETC structure that defines the format, medium, and target device to use when passing the data. It is possible to specify more than one medium by using the Boolean OR operator, allowing the method to choose the best medium among those specified.
  • pmedium
    [out] Pointer to the STGMEDIUM structure that indicates the storage medium containing the returned data through its TYMED member and the responsibility for releasing the medium through the value of its pUnkForRelease member.

    If pUnkForRelease is NULL, the receiver of the medium is responsible for releasing it; otherwise, pUnkForRelease points to the IUnknown interface on the appropriate object so its Release method can be called.

    The medium must be allocated and filled in by IDataObject::GetData.

Return Value

This method supports the standard return values E_INVALIDARG, E_UNEXPECTED, and E_OUTOFMEMORY.

The following table shows the additional return values for this method.

Value Description

S_OK

Data was successfully retrieved and placed in the storage medium provided.

DV_E_LINDEX

Invalid value for lindex; currently, only -1 is supported.

DV_E_FORMATETC

Invalid value for pFormatetc.

DV_E_TYMED

Invalid TYMED value.

DV_E_DVASPECT

Invalid dwAspect value.

OLE_E_NOTRUNNING

The object application is not running.

STG_E_MEDIUMFULL

An error occurred when allocating the medium.

Remarks

A data consumer calls IDataObject::GetData to retrieve data from a data object, conveyed through a storage medium (defined through the STGMEDIUM structure).

Notes to Callers

You can specify more than one acceptable TYMED medium with the Boolean OR operator. IDataObject::GetData must choose the medium that best represents the data from the OR values, do the allocation, and indicate responsibility for releasing the medium.

Data transferred across a stream extends from position zero of the stream pointer through to the position immediately before the current stream pointer (that is, the stream pointer position on exit).

To determine whether the platform supports this interface, see Determining Supported COM APIs.

Notes to Implementers

IDataObject::GetData must check all fields in the FORMATETC structure. It is important that IDataObject::GetData render the requested aspect and, if possible, use the requested medium.

If the data object cannot comply with the information specified in the FORMATETC, the method should return DV_E_FORMATETC.

If an attempt to allocate the medium fails, the method should return STG_E_MEDIUMFULL.

It is important to fill in all of the fields in the STGMEDIUM structure.

Although the caller can specify more than one medium for returning the data, IDataObject::GetData can supply only one medium.

If the initial transfer fails with the selected medium, this method can be implemented to try one of the other media specified before returning an error.

Requirements

Header objidl.h, objidl.idl
Library ole32.lib, uuid.lib
Windows Embedded CE Windows CE 3.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also

Reference

IDataObject::GetDataHere
IDataObject::SetData
FORMATETC
STGMEDIUM