c++选取目录

C/C++ code

    
    
    
    
CString GetDirPath() { CString strPath = "" ; BROWSEINFO bInfo; ZeroMemory( & bInfo, sizeof (bInfo)); bInfo.hwndOwner = m_hWnd; bInfo.lpszTitle = _T( " 请选择存放数据的文件夹: " ); bInfo.ulFlags = BIF_RETURNONLYFSDIRS; LPITEMIDLIST lpDlist; // 用来保存返回信息的IDList lpDlist = SHBrowseForFolder( & bInfo) ; // 显示选择对话框 if (lpDlist != NULL) // 用户按了确定按钮 { TCHAR chPath[ 255 ]; // 用来存储路径的字符串 SHGetPathFromIDList(lpDlist, chPath); // 把项目标识列表转化成字符串 strPath = chPath; // 将TCHAR类型的字符串转换为CString类型的字符串 } return strPath; }

你可能感兴趣的:(c++选取目录)