VC打开多个文件对话框

try
{
CString str("",10000);//这是做为存放打开文件名和路径的字符串空间10000这个值的设置就觉得有些不妥当
CFileDialog openfile(true,NULL,NULL,
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT,"All Files(*.*)|*.*|",AfxGetMainWnd());
openfile.m_ofn.lpstrFile=str.GetBuffer(10000);
openfile.m_ofn.nMaxFile=10000;
openfile.m_ofn.lStructSize=sizeof(openfile.m_ofn);
CString pathname("",MAX_PATH);
CFileStatus status;
openfile.DoModal();

POSITION mPos=openfile.GetStartPosition();
while(mPos!=NULL){
pathname=openfile.GetNextPathName(mPos);
CFile::GetStatus(pathname,status);
this->m_listresult.InsertItem(count++,pathname); //把包括路径在内的文件名写到一个list控件里
}
}
catch (CException* e)
{
AfxMessageBox(_T("打开文件出错了!"));
e->Delete();
}

原文地址:https://www.cnblogs.com/joeblackzqq/p/1910900.html