checkWidget(); if (transfer == null) DND.error(SWT.ERROR_NULL_ARGUMENT);   int[] ppv = new int[1]; int retryCount = 0; int result = COM.OleGetClipboard(ppv); while (result != COM.S_OK && retryCount++ < 10) { try { Thread.sleep(50);} catch (Throwable t) {} MSG msg = new MSG(); COM.PeekMessage (msg, 0, 0, 0, OS.PM_NOREMOVE | OS.PM_NOYIELD); result = COM.OleGetClipboard(ppv); } if (result != COM.S_OK) return null; IDataObject dataObject = new IDataObject(ppv[0]); try { TransferData[] allowed = transfer.getSupportedTypes(); for (int i = 0; i < allowed.length; i++) { if (dataObject.QueryGetData(allowed[i].formatetc) == COM.S_OK) { TransferData data = allowed[i]; data.pIDataObject = ppv[0]; return transfer.nativeToJava(data); } } } finally { dataObject.Release(); } return null;
return getContents(transfer, DND.CLIPBOARD);
public Object getContents(Transfer transfer) {	checkWidget();	if (transfer == null) DND.error(SWT.ERROR_NULL_ARGUMENT);	/*	* Bug in Windows. When a new application takes control	* of the clipboard, other applications may open the 	* clipboard to determine if they want to record the 	* clipoard updates.  When this happens, the clipboard 	* can not be accessed until the other application is	* finished.  To allow the other applications to release	* the clipboard, use PeekMessage() to enable cross thread	* message sends.	*/	int[] ppv = new int[1];	int retryCount = 0;	int result = COM.OleGetClipboard(ppv);	while (result != COM.S_OK && retryCount++ < 10) {		try { Thread.sleep(50);} catch (Throwable t) {}		MSG msg = new MSG();		COM.PeekMessage (msg, 0, 0, 0, OS.PM_NOREMOVE | OS.PM_NOYIELD);		result = COM.OleGetClipboard(ppv);	}	if (result != COM.S_OK) return null;	IDataObject dataObject = new IDataObject(ppv[0]);	try {		TransferData[] allowed = transfer.getSupportedTypes();		for (int i = 0; i < allowed.length; i++) {			if (dataObject.QueryGetData(allowed[i].formatetc) == COM.S_OK) {				TransferData data = allowed[i];				data.pIDataObject = ppv[0];				return transfer.nativeToJava(data);			}		}			} finally {		dataObject.Release();	}	return null; // No data available for this transfer}