OleGetClipboardWithEnterpriseInfo function (ole2.h)
Enables Windows Information Protection enlightened
applications to retrieve an IDataObject from the OLE Clipboard
accompanied by Windows Information Protection information about the data and the
source application.This information allows the
enlightened application to take over responsibility for applying Windows Information Protection
policy, including flying any appropriate UI prompts, and
auditing cases where the user explicitly approves copying
enterprise data into a personal context.
If the calling application is not enlightened, or is
configured as "unallowed" to access enterprise data,
then this call behaves exactly like OleGetClipboard - applying policy before deciding what IDataObject to return,
and supplying empty strings as output.
Syntax
HRESULT OleGetClipboardWithEnterpriseInfo(
[out] IDataObject **dataObject,
[out] PWSTR *dataEnterpriseId,
[out] PWSTR *sourceDescription,
[out] PWSTR *targetDescription,
[out] PWSTR *dataDescription
);
Parameters
[out] dataObject
Address of IDataObject pointer variable that receives the interface pointer to the clipboard data object.
[out] dataEnterpriseId
The enterprise id of the application that set the clipboard data. If the data is personal, this will be an empty string.
[out] sourceDescription
The description of the application that set the clipboard.
[out] targetDescription
The description of the caller's application to be used in auditing.
[out] dataDescription
The description of the data object to be used in auditing.
Return value
This function returns S_OK on success. Other possible values include the following.
Return code | Description |
---|---|
|
The OpenClipboard function used within OleFlushClipboard failed. |
|
The CloseClipboard function used within OleFlushClipboard failed. |
Remarks
OleGetClipboardWithEnterpriseInfo handles three cases:
- The application that placed data on the clipboard with the OleSetClipboard function is still running.
- The application that placed data on the clipboard with the OleSetClipboard function has subsequently called the OleFlushClipboard function.
- There is data from a non-OLE application on the clipboard.
In the second case, OLE creates a default data object and returns it to the user. Because the data on the clipboard originated from an OleSetClipboard call, the OLE-provided data object contains more accurate information about the type of data on the clipboard. In particular, the original medium (TYMED) on which the data was offered is known. Thus, if a data-source application offers a particular clipboard format, for example cfFOO, on a storage object and calls the OleFlushClipboard function, the storage object is copied into memory and the hglobal memory handle is put on the clipboard. Then, when the OleGetClipboardWithEnterpriseInfo function creates its default data object, the hglobal from the clipboard again becomes an IStorage object. Furthermore, the FORMATETC enumerator and the IDataObject::QueryGetData method would all correctly indicate that the original clipboard format (cfFOO) is again available on a TYMED_ISTORAGE.
In the third case, OLE still creates a default data object, but there is no special information about the data in the clipboard formats (particularly for application-defined Clipboard formats). Thus, if an hGlobal-based storage medium were put on the clipboard directly by a call to the SetClipboardData function, the FORMATETC enumerator and the IDataObject::QueryGetData method would not indicate that the data was available on a storage medium. A call to the IDataObject::GetData method for TYMED_ISTORAGE would succeed, however. Because of these limitations, it is strongly recommended that OLE-aware applications interact with the clipboard using the OLE clipboard functions.
The clipboard data object created by the OleGetClipboardWithEnterpriseInfo function has a fairly extensive IDataObject implementation. The OLE-provided data object can convert OLE 1 clipboard format data into the representation expected by an OLE 2 caller. Also, any structured data is available on any structured or flat medium, and any flat data is available on any flat medium. However, GDI objects (such as metafiles and bitmaps) are only available on their respective mediums.
Note that the tymed member of the FORMATETC structure used in the FORMATETC enumerator contains the union of supported mediums. Applications looking for specific information (such as whether CF_TEXT is available on TYMED_HGLOBAL) should do the appropriate bitmasking when checking this value.
If you call the OleGetClipboardWithEnterpriseInfo function, you should only hold on to the returned IDataObject for a very short time. It consumes resources in the application that offered it.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 10 [desktop apps only] |
Minimum supported server | Windows Server 2016 [desktop apps only] |
Target Platform | Windows |
Header | ole2.h |
Library | Ole32.lib |
DLL | Ole32.dll |