TCHAR buffer = new TCHAR(0, size / TCHAR.sizeof);
char[] chars = new char[size/2];
public Object nativeToJava(TransferData transferData){	if (!isSupportedType(transferData) || transferData.pIDataObject == 0) return null;		IDataObject data = new IDataObject(transferData.pIDataObject);	data.AddRef();	FORMATETC formatetc = transferData.formatetc;	STGMEDIUM stgmedium = new STGMEDIUM();	stgmedium.tymed = COM.TYMED_HGLOBAL;		transferData.result = data.GetData(formatetc, stgmedium);	data.Release();	if (transferData.result != COM.S_OK) return null;	int hMem = stgmedium.unionField;	try {		switch (transferData.type) {			case CF_UNICODETEXTID: {				/* Ensure byteCount is a multiple of 2 bytes on UNICODE platforms */				int size = COM.GlobalSize(hMem) / TCHAR.sizeof * TCHAR.sizeof;				if (size == 0) return null;				TCHAR buffer = new TCHAR(0, size / TCHAR.sizeof);				int ptr = COM.GlobalLock(hMem);				if (ptr == 0) return null;				try {					COM.MoveMemory(buffer, ptr, size);					return buffer.toString(0, buffer.strlen());				} finally {					COM.GlobalUnlock(hMem);					}			}			case CF_TEXTID: {				int lpMultiByteStr = COM.GlobalLock(hMem);				if (lpMultiByteStr == 0) return null;				try {					int cchWideChar = COM.MultiByteToWideChar (CodePage, COM.MB_PRECOMPOSED, lpMultiByteStr, -1, null, 0);					if (cchWideChar == 0) return null;					char[] lpWideCharStr = new char [cchWideChar - 1];					COM.MultiByteToWideChar (CodePage, COM.MB_PRECOMPOSED, lpMultiByteStr, -1, lpWideCharStr, lpWideCharStr.length);					return new String(lpWideCharStr);				} finally {					COM.GlobalUnlock(hMem);				}			}		}	} finally {		COM.GlobalFree(hMem);	}	return null;}