CString str;//声明一个字符串
BROWSEINFO bi;
char name[MAX_PATH];
ZeroMemory(&bi,sizeof(BROWSEINFO));
bi.hwndOwner = GetSafeHwnd();
bi.pszDisplayName = name;
bi.lpszTitle = "Select folder";
//bi.ulFlags = BIF_USENEWUI;
bi.ulFlags = BIF_RETURNFSANCESTORS;
LPITEMIDLIST idl = SHBrowseForFolder(&bi);
if(idl == NULL)
return;
SHGetPathFromIDList(idl, str.GetBuffer(MAX_PATH));
str.ReleaseBuffer();
CString m_strPath;
m_strPath = str;//为对话框中与一编辑框对应的CString型变量,保存并显示选中的路径。
if(str.GetAt(str.GetLength()-1)!='\\')
m_strPath+="\\";
UpdateData(FALSE);
AfxMessageBox(m_strPath);
MFC 选择路径
最新推荐文章于 2023-07-20 16:24:16 发布