in the code below, When GlobalFree is called, an error occurs in GlobalAlloc when GetClipboardData is called.
MSDN doesn't mention GlobalFree when calling SetClipboardData.
if (OpenClipboardEx(m_hViewer))
{
hglbCopy = GlobalAlloc(GMEM_MOVEABLE,
lptstrCopy = (LPTSTR)GlobalLock(hglbCopy);
memcpy(lptstrCopy, &szTest, cch * sizeof(TCHAR));
lptstrCopy[cch] = (TCHAR)0;
GlobalUnlock(hglbCopy);
::SetClipboardData(CF_UNICODETEXT, hglbCopy);
CloseClipboard();
**GlobalFree(hglbCopy);**
}
So when GloballAlloc is called, I thought that GlobalFree calls were natural.
Some Internet articles say that GlobalFree should not be called, but I can't see any official information related to MSDN.
If you know anything about this, please reply.
thank you.
My previous question
clipboard-getclipboard-globallock-fail-1.html