Returns an object to enumerate the FORMATETC structures that can be used with IDataObject::GetData or IDataObject::SetData. You use this method when you want to enumerate the FORMATETC structures for a data object.

HRESULT EnumFormatEtc(

DWORD dwDirection,
//Specifies a value from the enumeration DATADIR
IEnumFORMATETC ** ppenumFormatetc
//Location for IEnumFORMATETC



[in]Specifies a value from the enumeration DATADIR.

typedef enum tagDATADIR





The value DATADIR_GET enumerates the formats that can be passed in IDataObject::GetData. The value DATADIR_SET enumerates those formats that can be passed in IDataObject::SetData.


[out]Points to the location where the new enumerator object should be returned.

Return Values


Enumerator object was successfully returned.


One or more arguments are invalid.


Enumerator object was not returned because the system ran out of memory.


The direction specified by dwDirection is not supported.


Requests that OLE enumerate the formats from the registry.


This method creates and returns an enumerator object that can be used to determine all of the ways the data object can describe data in a FORMATETC structure. The enumerator object implements IEnumFORMATETC, one of the standard enumerator interfaces. The caller is responsible for calling IEnumFormatEtc::Release when it is finished with the enumeration.

If a FORMATETC structure is enumerated by IDataObject::EnumFormatEtc, there is no guarantee that the format is supported because the formats can change over time. Accordingly, applications should treat the enumeration as a hint of the format types that can be passed.

IDataObject::EnumFormatEtc is called when one of the following actions occurs:

  • An application calls OleSetClipboard. OLE must determine what data to place on the Clipboard and whether it is necessary to put OLE 1 compatibility formats on the Clipboard.

  • Data is being pasted from the Clipboard or dropped. An application uses the first acceptable format.

  • The Paste Special dialog box is displayed. The target application builds the list of formats from the FORMATETC entries.

Formats can be registered statically in the registration database or dynamically during object initialization. If an object has an unchanging list of formats and these formats are registered in the registration database, it can ask OLE to perform the enumeration using the registration database by calling the helper function OleRegEnumFormatEtc or by returning OLE_S_USEREG.

OLE_S_USEREG instructs the default object handler to call OleRegEnumFormatEtc. Object applications that are implemented as DLL object applications cannot return OLE_S_USEREG. They must call OleRegEnumFormatEtc directly.

Private formats can be enumerated for OLE 1 objects, if they are registered with the RequestDataFormats or SetDataFormats keys in the registration database. Also, private formats can be enumerated for OLE 2 objects, if they are registered with the GetDataFormats or SetDataFormats keys.

For OLE 1 objects whose servers do not have RequestDataFormats or SetDataFormats information registered in the registration database, a call to EnumFormatEtc with DATADIR_GET only enumerates the Native and Metafile formats, regardless of whether they support these formats or others. Calling EnumFormatEtc with DATADIR_SET on such objects only enumerates Native, regardless of whether the object supports being set with other formats.

The FORMATETC structure returned by the enumeration usually indicates a NULL target device (ptd). This is appropriate because, unlike the other members of FORMATETC, the target device does not participate in the object's decision as to whether it can accept or provide the data in either a SetData or GetData call.

The TYMED member of FORMATETC often indicates that more than one kind of storage medium is acceptable. You should always mask and test for it by using a Boolean OR operator.

See Also

FORMATETC, OleRegEnumFormatEtc, IEnumFormatEtc, IDataObject::SetData, IDataObject::GetData

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database