0
我有一個MFC應用程序來查找剪貼板中的文件,它在複製文件時工作正常,但在剪切和粘貼操作過程中失敗。當我住調試它表明GetClipboardData(CF_HDROP)將失敗並返回錯誤NO 1418 這裏是我的代碼GetClipboardData(CF_HDROP)在剪切和粘貼中失敗
TCHAR lpszFileName[MAX_PATH];
bool bStart = true;
CString csFile ="",
strErr = "";
bool bOpen = OpenClipboard(0);
if(!bOpen)
{
strErr.Format("clipboard Error %d",GetLastError());
WriteLog(TYPECAST_T0_LPTSTR strErr,1,1);
}
HGLOBAL hGlobal = (HGLOBAL)GetClipboardData(CF_HDROP);
if (hGlobal)
{
HDROP hDrop = (HDROP)GlobalLock(hGlobal);
if (hDrop)
{
UINT fileCount = DragQueryFile(hDrop, 0xFFFFFFFF, 0, 0);
UINT filenameLength;
for (UINT i = 0; i < fileCount; ++i)
{
filenameLength = DragQueryFile(hDrop, i, 0, 0);
DragQueryFile(hDrop, i, lpszFileName, filenameLength+1);
csFile = (CString)lpszFileName;
AddFileList(csFile);
}
}
}
else
{
strErr.Format("clipboard Error %d",GetLastError());
WriteLog(TYPECAST_T0_LPTSTR strErr,1,1);
}
CloseClipboard();
GlobalUnlock(hGlobal);
如果有人konws如何解決這個問題,請分享