VC6 带“新建”浏览文件夹
CString MyBrowseFolder()
{
TCHAR chPath[MAX_PATH]; //用来存储路径的字符串
CString strPath;
BROWSEINFO bInfo;
GetModuleFileName(NULL,chPath,MAX_PATH);
strPath=chPath;
ZeroMemory(&bInfo, sizeof(bInfo));
bInfo.hwndOwner = ::AfxGetMainWnd()->m_hWnd;
bInfo.lpszTitle = _T("请选择路径: ");
bInfo.ulFlags = BIF_RETURNONLYFSDIRS|0x40;
bInfo.lParam = (LPARAM)strPath.GetBuffer(strPath.GetLength());
LPITEMIDLIST lpDlist; //用来保存返回信息的IDList
lpDlist = SHBrowseForFolder(&bInfo) ; //显示选择对话框
strPath=_T("");
if(lpDlist != NULL) //用户按了确定按钮
{
SHGetPathFromIDList(lpDlist, chPath);//把项目标识列表转化成字符串
strPath.Format(_T("%s"),chPath); //将TCHAR类型的字符串转换为CString类型的字符串
}
return strPath;
}
{
TCHAR chPath[MAX_PATH]; //用来存储路径的字符串
CString strPath;
BROWSEINFO bInfo;
GetModuleFileName(NULL,chPath,MAX_PATH);
strPath=chPath;
ZeroMemory(&bInfo, sizeof(bInfo));
bInfo.hwndOwner = ::AfxGetMainWnd()->m_hWnd;
bInfo.lpszTitle = _T("请选择路径: ");
bInfo.ulFlags = BIF_RETURNONLYFSDIRS|0x40;
bInfo.lParam = (LPARAM)strPath.GetBuffer(strPath.GetLength());
LPITEMIDLIST lpDlist; //用来保存返回信息的IDList
lpDlist = SHBrowseForFolder(&bInfo) ; //显示选择对话框
strPath=_T("");
if(lpDlist != NULL) //用户按了确定按钮
{
SHGetPathFromIDList(lpDlist, chPath);//把项目标识列表转化成字符串
strPath.Format(_T("%s"),chPath); //将TCHAR类型的字符串转换为CString类型的字符串
}
return strPath;
}