// TODO: Add your control notification handler code here
UpdateData();
int size = 8192;
char *buffer = new char[size];
memset(buffer,0,size);
CFileDialog dlg(TRUE);
dlg.m_ofn.Flags =  OFN_ALLOWMULTISELECT|OFN_EXPLORER|OFN_ENABLEHOOK;
if(m_mmType == 0)
dlg.m_ofn .lpstrFilter = "mpg(*.mpg,*.m2v,*.mp2,*.avi)\0*.mpg;*.m2v;*.mp2;*.avi\0\0";
else if(m_mmType == 1)
dlg.m_ofn .lpstrFilter = "WAV(*.wav)\0*.wav\0\0";
else if(m_mmType == 2)
dlg.m_ofn .lpstrFilter = "cg(*.*)\0*.*\0\0";
dlg.m_ofn.lpstrFile = buffer;
dlg.m_ofn.nMaxFile = size;

CString fname;
POSITION pos;
if(dlg.DoModal() != IDOK)
return;
int index;
int count = 0;
pos = dlg.GetStartPosition();
while(pos != NULL)
{
fname = dlg.GetNextPathName(pos);
index = m_List.InsertString(-1,fname);
count ++;
m_List.SetItemData(index,0);
}
delete buffer;
CString msg;
msg.Format("共%03d文件",count);
SetDlgItemText(IDC_INFO,msg);

解决方案 »

  1.   

    int size = 8192; 在某些情况下可能太大了看看 msdn
    FIX: Common File Dialog Multiple Selection File Limit
    ......
    SYMPTOMS
    When you use the GetOpenFileName API or the MFC CFileDialog class with the OFN_ALLOWMULTISELECT flag on Windows NT 4.0, you are limited to the number of characters that will be returned in the file name buffer. 
    ......
    There is a bug in Windows NT 4.0 that limits the number of characters that will be copied to lpstrFile to 2,562 characters no matter what size is specified in nMaxFile. When this occurs, the function returns IDOK, but the file list in lpstrFile is truncated at this limit.