OleCreateStaticFromData function (ole2.h)

Creates a static object, that contains only a representation, with no native data, from a data transfer object.

Note  The OLESTREAM to IStorage conversion functions also convert static objects.


HRESULT OleCreateStaticFromData(
  [in]  LPDATAOBJECT    pSrcDataObj,
  [in]  REFIID          iid,
  [in]  DWORD           renderopt,
  [in]  LPFORMATETC     pFormatEtc,
  [in]  LPOLECLIENTSITE pClientSite,
  [in]  LPSTORAGE       pStg,
  [out] LPVOID          *ppvObj


[in] pSrcDataObj

Pointer to the IDataObject interface on the data transfer object that holds the data from which the object will be created.

[in] iid

Reference to the identifier of the interface with which the caller is to communicate with the new object (usually IID_IOleObject, defined in the OLE headers as the interface identifier for IOleObject).

[in] renderopt

Value from the enumeration OLERENDER indicating the locally cached drawing or data-retrieval capabilities that the container wants in the newly created component. It is an error to pass the render options OLERENDER_NONE or OLERENDER_ASIS to this function.

[in] pFormatEtc

Depending on which of the OLERENDER flags is used as the value of renderopt, may be a pointer to one of the FORMATETC enumeration values. Refer to the OLERENDER enumeration for restrictions.

[in] pClientSite

Pointer to an instance of IOleClientSite, the primary interface through which the object will request services from its container. This parameter can be NULL.

[in] pStg

Pointer to the IStorage interface for storage for the object. This parameter cannot be NULL.

[out] ppvObj

Address of pointer variable that receives the interface pointer requested in riid. Upon successful return, *ppvObj contains the requested interface pointer on the newly created object.

Return value

This function returns S_OK on success.


The OleCreateStaticFromData function can convert any object, as long as it provides an IDataObject interface, to a static object. It is useful in implementing the Convert To Picture option for OLE linking or embedding.

Static objects can be created only if the source supports one of the OLE-rendered clipboard formats: CF_METAFILEPICT, CF_DIB, or CF_ BITMAP, and CF_ENHMETAFILE.

You can also call OleCreateStaticFromData to paste a static object from the clipboard. To determine whether an object is static, call the OleQueryCreateFromData function, which returns OLE_S_STATIC if one of CF_METAFILEPICT, CF_DIB, CF_BITMAP, or CF_ENHMETAFILE is present and an OLE format is not present. This indicates that you should call OleCreateStaticFromData rather than the OleCreateFromData function to create the object.

The new static object is of class CLSID_StaticMetafile in the case of CF_METAFILEPICT, CLSID_StaticDib in the case of CF_DIB or CF_BITMAP, or CLSID_Picture_EnhMetafile in the case of CF_ENHMETAFILE. The static object sets the OLEMISC_STATIC and OLE_CANTLINKINSIDE bits returned from IOleObject::GetMiscStatus. The static object will have the aspect DVASPECT_CONTENT and a LINDEX of -1.

The pSrcDataObject is still valid after OleCreateStaticFromData returns. It is the caller's responsibility to free pSrcDataObject - OLE does not release it.

There cannot be more than one presentation stream in a static object.


Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header ole2.h
Library Ole32.lib
DLL Ole32.dll

See also