1.响应系统消息 WM_DROPFILES
2.在响应函数里面获取拖拽文件路径
1 LRESULT OnDropFiles(UINT uMsg, WPARAM wParam, LPARAM lParam) 2 { 3 HDROP hDropInfo = (HDROP)wParam; 4 5 TCHAR filePath[80*MAX_PATH] = {0}; 6 7 int nFileCount; 8 9 nFileCount = ::DragQueryFile(hDropInfo , 0xFFFFFFFF, NULL, 0);//获取文件个数 10 11 //获取拖拽的文件的路径 12 for (int i = 0 ;i < nFileCount ; i++) 13 { 14 ::DragQueryFile(hDropInfo , i , (LPTSTR)filePath ,1024); 15 16 std::vector<wstring> vctString(1, filePath); 17 18 wstring wstrFile = filePath; 19 20 m_attString.push_back(wstrFile);//文件路径保存下来,CreateMail时使用 21 22 AddFiles(vctString); 23 } 24 25 ::DragFinish (hDropInfo); 26 27 return 0; 28 }