如果是dialog,窗口要加上accept files属性
//拖放文件响应
void CXXXXX::OnDropFiles(HDROP hDrop)
{
CString strPath;
UINT nChars=::DragQueryFile(hDrop,0,NULL,0);
TCHAR* lpszFileName=new TCHAR[nChars+1];
nChars=::DragQueryFile(hDrop,0,lpszFileName,nChars+1);
::DragFinish(hDrop);
CString str(lpszFileName);
AfxMessageBox(str);
delete []lpszFileName;
}
//拖放文件响应
void CXXXXX::OnDropFiles(HDROP hDrop)
{
CString strPath;
UINT nChars=::DragQueryFile(hDrop,0,NULL,0);
TCHAR* lpszFileName=new TCHAR[nChars+1];
nChars=::DragQueryFile(hDrop,0,lpszFileName,nChars+1);
::DragFinish(hDrop);
CString str(lpszFileName);
AfxMessageBox(str);
delete []lpszFileName;
}