MFC实现选择文件夹代码

void SelectPath(CString &strPath)
{
TCHAR szPath[MAX_PATH];
BROWSEINFO br;
ITEMIDLIST* pItem;


br.hwndOwner = this->GetSafeHwnd();
br.pidlRoot = 0;
br.pszDisplayName = 0;
br.lpszTitle ="选择路径";
br.ulFlags = BIF_STATUSTEXT;
br.lpfn = 0;
br.iImage = 0;
br.lParam = 0;
 
pItem = SHBrowseForFolder(&br);
if(pItem != NULL)
{
if(SHGetPathFromIDList(pItem,szPath) == TRUE)
{
strPath = szPath;
}
else
{
   //解析失败弹出对话框提示
}
}
else
{
//取消不做处理
}
}

你可能感兴趣的:(MFC实现选择文件夹代码)