Unicode encoding under Setclipbdata

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.