BROWSEINFO bi;
char buffer[MAX_PATH];
ZeroMemory(buffer, MAX_PATH);
bi.hwndOwner = GetSafeHwnd();
bi.pidlRoot = NULL;
bi.pszDisplayName = (LPWSTR)buffer;
bi.lpszTitle = _T("请选择文件夹");
bi.ulFlags = BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS;
bi.lpfn = NULL;
bi.lParam = 0;
bi.iImage = 0;
LPITEMIDLIST pList = NULL;
if ((pList = SHBrowseForFolder(&bi)) != NULL)
{
char path[MAX_PATH];
ZeroMemory(path, MAX_PATH);
SHGetPathFromIDList(pList, (LPWSTR)path);
m_strShowFileInfo.Format(_T("%s"), path);//保存路径
UpdateData(FALSE);
}
//下面这个是不带新建功能的
char szPath[MAX_PATH]; //存放选择的目录路径
//CString str;
ZeroMemory(szPath, sizeof(szPath));
BROWSEINFO bi;
bi.hwndOwner = m_hWnd;
bi.pidlRoot = NULL;
bi.pszDisplayName = (LPWSTR)szPath;
bi.lpszTitle = _T("请选择需要打包的目录:");
bi.ulFlags = 0;
bi.lpfn = NULL;
bi.lParam = 0;
bi.iImage = 0;
//弹出选择目录对话框
LPITEMIDLIST lp = SHBrowseForFolder(&bi);
if(lp && SHGetPathFromIDList(lp, (LPWSTR)szPath))
{
m_strShowFileInfo.Format(_T("%s"), szPath);
UpdateData(FALSE);
}
else
AfxMessageBox(_T("无效的目录,请重新选择"));