[MFC]剪贴板的问题,求助,
void CnotebookView::OnFileCopy(){
// TODO: 在此添加命令处理程序代码
int nStart,nEnd;
CEdit strSel;
strSel.GetSel(nStart,nEnd);
CString str;
strSel.GetWindowTextA(str);
DWORD dSize = (nEnd - nStart +1) *sizeof (TCHAR);
HANDLE hGlobalMemory = GlobalAlloc(GMEM_MOVEABLE, dSize);
LPBYTE lpGlobalMemory = (LPBYTE)GlobalLock(hGlobalMemory);
memcpy_s(hGlobalMemory, dSize, strSel, dSize);
GlobalUnlock(hGlobalMemory);
HWND hWnd = GetSafeHwnd();
::OpenClipboard(hWnd);
::EmptyClipboard();
::SetClipboardData(CF_UNICODETEXT, hGlobalMemory);
::CloseClipboard();
}
用的是MFC中间的多文档,程序一运行就说系统错误,调试的时候,发现,那个STR是指向错误的指针,初学做记事本,希望大侠们帮帮忙。