For a long time, either SetClipboardData interrupted, or only the first letter can be copied.
Only the first letter can be copied because the Unicode under CString cast wchar_t* not work. The SetClipboardData interrupt is due to the wcscpy_s copy of the string to the memory address rsize_t is incorrect. The following is the code for OK: if (OpenClipboard ()) {CString temp; GetDlgItemText (idc_edit1, temp); EmptyClipboard (); Hglobal Hmem=null;hmem = GlobalAlloc (Ghnd, (1+temp. GetLength ()) *sizeof (CString)) wchar_t *lps;lps= (wchar_t *) GlobalLock (HMEM); wchar_t *TEMPC;TEMPC = temp. GetBuffer (0); temp. ReleaseBuffer (); wcscpy_s (LPs, (Wcslen (TEMPC) +1) *sizeof (wchar_t), TEMPC); GlobalUnlock (HMEM); SetClipboardData (Cf_unicodetext, hmem);D word dw=getlasterror (); CloseClipboard (); MessageBox (L "copy succeeded");
Unicode encoding under Setclipbdata