用CFileDialog打开多个文件

 POSITION   pos;   
  CString   strFilename;   
  CFileDialog     FileDlg(TRUE,"txt",NULL,OFN_HIDEREADONLY|OFN_FILEMUSTEXIST|OFN_EXPLORER|OFN_ALLOWMULTISELECT,   "Text   Files(*.txt)|*.txt|All   Files(*.*)|*.*|");   
  FileDlg.m_ofn.nMaxFile   =   100   *   MAX_PATH;     // 100   Files   
  FileDlg.m_ofn.lpstrFile   =    new   TCHAR[FileDlg.m_ofn.nMaxFile];   
  ZeroMemory(FileDlg.m_ofn.lpstrFile,    sizeof(TCHAR)   *   FileDlg.m_ofn.nMaxFile);   
   if(FileDlg.DoModal()   ==   IDOK)   
  {   
          pos   =   FileDlg.GetStartPosition();   
           while(pos)   
          {   
                  strFilename   =   FileDlg.GetNextPathName(pos);   
                  AfxMessageBox(strFilename);   
          }   
  }

猜你喜欢

转载自blog.csdn.net/eamon100/article/details/89334201