真的很怪,在SDI的MainFrm中的Open项简单的添加:
CFileDialog dlg(TRUE, NULL, NULL, OFN_FILEMUSTEXIST, "SRC(*.TXT)|*.TXT||"); 
if(dlg.DoModal()==IDOK)AfxMessageBox(dlg.GetPathName());
运行:当打开的是桌面上的txt文件时,连续打开两次或三次,就会出现Access violation;提示的是wincore.cpp,line:958 error;但若打开的是桌面之外的txt文件,却连续多次打开也不会出现问题;这个程序总共就这几行,难道是CFileDialog的问题???我用的是:vc6+sp6

解决方案 »

  1.   

    那你用api来写吧,看看会不会出现错误.OPENFILENAME ofn;       // common dialog box structure
    char szFile[260];       // buffer for file name
    HWND hwnd;              // owner window// Initialize OPENFILENAME
    ZeroMemory(&ofn, sizeof(ofn));
    ofn.lStructSize = sizeof(ofn);
    ofn.hwndOwner = GetSafeHwnd();
    ofn.lpstrFile = szFile;
    //
    // Set lpstrFile[0] to '\0' so that GetOpenFileName does not 
    // use the contents of szFile to initialize itself.
    //
    ofn.lpstrFile[0] = '\0';
    ofn.nMaxFile = sizeof(szFile);
    ofn.lpstrFilter = "All\0*.*\0Text\0*.TXT\0";
    ofn.nFilterIndex = 1;
    ofn.lpstrFileTitle = NULL;
    ofn.nMaxFileTitle = 0;
    ofn.lpstrInitialDir = NULL;
    ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;// Display the Open dialog box. if (GetOpenFileName(&ofn)==TRUE) 
    {
       AfxMessageBox(ofn.lpstrFile);
    }
      

  2.   

    我是怀疑是否是传说中的bug呢?
    http://www.jr163.org/cup1/3897/3897560.htm