//选择文件夹
CString GetDirectory()
{
BROWSEINFO bi;
char name[MAX_PATH];
ZeroMemory(&bi,sizeof(BROWSEINFO));
bi.hwndOwner = AfxGetMainWnd()->GetSafeHwnd();
bi.pszDisplayName = name;
bi.lpszTitle = "选择文件夹目录";
bi.ulFlags = BIF_RETURNFSANCESTORS;
LPITEMIDLIST idl = SHBrowseForFolder(&bi);
if(idl == NULL)
return "";
CString strDirectoryPath;
SHGetPathFromIDList(idl, strDirectoryPath.GetBuffer(MAX_PATH));
strDirectoryPath.ReleaseBuffer();
if(strDirectoryPath.IsEmpty())
return "";
if(strDirectoryPath.Right(1)!="\\")
strDirectoryPath+="\\";
return strDirectoryPath;
}
温馨提示:答案为网友推荐,仅供参考