Windows中用鼠标拖放文件

Windows中用鼠标拖放文件

添加对WM_DROPFILES响应的函数
void CMyDlg::OnDropFiles(HDROP hDropInfo)
{
 char szFilePath[MAX_PATH];
 int nFileCount;
//取得拖放的文件个数
 nFileCount = DragQueryFile(hDropInfo, 0xFFFFFFFF, NULL, MAX_PATH);

 //获取拖放的文件路径
 UINT nCharNum = DragQueryFile(hDropInfo, 0, szFilePath, MAX_PATH);
 //szFilePath中保存着文件路径或者一个目录
//doSomething();
 
 DragFinish(hDropInfo);
 CDialog::OnDropFiles(hDropInfo);
}

你可能感兴趣的:(Windows中用鼠标拖放文件)