CString xxxxx::getDirPath()
{
char dirPath[MAX_PATH]; /* 存放选择的目录路径 */
CString tmp;
ZeroMemory( dirPath, sizeof(dirPath) );
BROWSEINFO bi;
bi.hwndOwner = m_hWnd;
bi.pidlRoot = NULL;
bi.pszDisplayName = dirPath;
bi.lpszTitle = "请选择需要打开的目录:";
bi.ulFlags = 0;
bi.lpfn = NULL;
bi.lParam = 0;
bi.iImage = 0;
LPITEMIDLIST lp = SHBrowseForFolder(&bi);
if ( (lp && SHGetPathFromIDList( lp, dirPath )) )
{
tmp.Format( "%s", dirPath );
}
else
{
MessageBox( "无效的目录,请重新选择", "系统消息", MB_OK | MB_ICONINFORMATION );
tmp.Empty();
}
return tmp;
}
{
char dirPath[MAX_PATH]; /* 存放选择的目录路径 */
CString tmp;
ZeroMemory( dirPath, sizeof(dirPath) );
BROWSEINFO bi;
bi.hwndOwner = m_hWnd;
bi.pidlRoot = NULL;
bi.pszDisplayName = dirPath;
bi.lpszTitle = "请选择需要打开的目录:";
bi.ulFlags = 0;
bi.lpfn = NULL;
bi.lParam = 0;
bi.iImage = 0;
LPITEMIDLIST lp = SHBrowseForFolder(&bi);
if ( (lp && SHGetPathFromIDList( lp, dirPath )) )
{
tmp.Format( "%s", dirPath );
}
else
{
MessageBox( "无效的目录,请重新选择", "系统消息", MB_OK | MB_ICONINFORMATION );
tmp.Empty();
}
return tmp;
}