I was the main code for this code , also mentioned in my other question . This version forces the char* character type, which breaks the compilation into my unicode project. Therefore, I made the following settings:
void SetClipboardText(CString & szData) { HGLOBAL h; LPTSTR arr; size_t bytes = (szData.GetLength()+1)*sizeof(TCHAR); h=GlobalAlloc(GMEM_MOVEABLE, bytes); arr=(LPTSTR)GlobalLock(h); ZeroMemory(arr,bytes); _tcscpy_s(arr, szData.GetLength()+1, szData); szData.ReleaseBuffer(); GlobalUnlock(h); ::OpenClipboard (NULL); EmptyClipboard(); SetClipboardData(CF_TEXT, h); CloseClipboard(); }
Copying looks great - it works in the debugger Visual Studio tells me that arr contains the copied string, as expected. But when I paste into any application, only the first character is inserted.
What will go wrong?
winapi
Mr. Boy
source share