还是用CFileDialog吗?dwFlag的参数应该设置成什么啊?
我在msdn里面找了半天也没有找到,请指点一下

解决方案 »

  1.   

    那是用shell,你找一找,应该有。
      

  2.   

    void CCBrowserDirDlg::OnOK() 
    { char lpBuffer[_MAX_PATH];

    // pointer to IMalloc
             LPMALLOC pMalloc = NULL;
    //Retrieves a pointer to the shell's IMalloc interface. 
             if (SHGetMalloc(&pMalloc)==E_FAIL) 
    {
    AfxMessageBox("IDS_ERR_SHGETMALLOC");
    return;
             }

    BROWSEINFO bi;
    ZeroMemory(&bi, sizeof(bi));
    // Fill in the BROWSEINFO structure. 
    bi.lpszTitle = "请选择";
    bi.hwndOwner =  m_hWnd;
    bi.pszDisplayName = lpBuffer; bi.ulFlags = BIF_NEWDIALOGSTYLE|BIF_DONTGOBELOWDOMAIN ;  //Displays a dialog box that enables the user to select a shell folder. 
    LPITEMIDLIST IIDList = SHBrowseForFolder(&bi);
    if(IIDList !=NULL)
    {
    //Converts an item identifier list to a file system path.
    SHGetPathFromIDList(IIDList, lpBuffer);
                      pMalloc->Free(IIDList);

    CString strDirectory = CString(lpBuffer);
    AfxMessageBox(strDirectory);
    }
    pMalloc->Release();
    pMalloc = NULL;
    }
      

  3.   

    取得文件名
    {
    cstring  
    filepathname;
    cfiledialog dlg(true);///true为open对话框,false为save as对话框
    if(dlg.domodal()==idok)
    filepathname=dlg.getpathname();
    }    
    相关信息:cfiledialog 用于取文件名的几个成员函数:
    假如选择的文件是c:\windows\test.exe
    则:
    (1)getpathname();取文件名全称,包括完整路径。取回c:\windows\test.exe
    (2)getfiletitle();取文件全名:test.exe
    (3)getfilename();取回test
    (4)getfileext();取扩展名exe
      

  4.   

    调用 Shell API,也就是 SH开头的。很多文件操作可以实现了。
      

  5.   

    CFileDialog filedlg(true,_t("exe"),_t("*.exe"),ofn_hidereadonly|ofn_overwriteprompt,(_t("executable files (*.exe) |*.exe ||")));//显示打开文件的对话框
    if(filedlg.domodal()==idok)//当操作者选择ok时,程序,取得选择文
    //件的全路径名(包括文件的路径及文件名称),并将相应的数值传输给相
    //关的控件变量。
    {
    m_filename=filedlg.getpathname();//m_filename是文件名称。
    }