if (clipdata3) SetClipboardData(RegisterClipboardFormat(CF_RTF), clipdata3);
void write_clip(wchar_t * data, int len, int must_deselect){    HGLOBAL clipdata;    HGLOBAL clipdata2;    int len2;    void *lock, *lock2;    len2 = WideCharToMultiByte(CP_ACP, 0, data, len, 0, 0, NULL, NULL);    clipdata = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE,			   len * sizeof(wchar_t));    clipdata2 = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, len2);    if (!clipdata || !clipdata2) {	if (clipdata)	    GlobalFree(clipdata);	if (clipdata2)	    GlobalFree(clipdata2);	return;    }    if (!(lock = GlobalLock(clipdata)))	return;    if (!(lock2 = GlobalLock(clipdata2)))	return;    memcpy(lock, data, len * sizeof(wchar_t));    WideCharToMultiByte(CP_ACP, 0, data, len, lock2, len2, NULL, NULL);    GlobalUnlock(clipdata);    GlobalUnlock(clipdata2);    if (!must_deselect)	SendMessage(hwnd, WM_IGNORE_CLIP, TRUE, 0);    if (OpenClipboard(hwnd)) {	EmptyClipboard();	SetClipboardData(CF_UNICODETEXT, clipdata);	SetClipboardData(CF_TEXT, clipdata2);	CloseClipboard();    } else {	GlobalFree(clipdata);	GlobalFree(clipdata2);    }    if (!must_deselect)	SendMessage(hwnd, WM_IGNORE_CLIP, FALSE, 0);}