//显示文件夹对话框,返回选中文件夹的路径
CString BrowseForFolder( HWND hWnd )
{
TCHAR szTitle[] = _T("Select a folder");
TCHAR szDisplayName[MAX_PATH] = _T("");
TCHAR szPath[MAX_PATH] = _T("");
BROWSEINFO bi;
bi.hwndOwner = hWnd;
bi.pidlRoot = NULL;
bi.lpszTitle = szTitle;
bi.pszDisplayName = szDisplayName;
bi.ulFlags = BIF_RETURNONLYFSDIRS;
bi.lpfn = NULL;
bi.lParam = 0;
LPITEMIDLIST pItemIDList = SHBrowseForFolder( &bi );
if( pItemIDList )
{
SHGetPathFromIDList(pItemIDList,szPath) ;
IMalloc *pMalloc;
if( SHGetMalloc( &pMalloc ) != NOERROR )
{
TRACE( "Failed to get pointer to shells task allocator" ) ;
return szPath;
}
pMalloc->Free( pItemIDList );
if( pMalloc )
pMalloc->Release();
}
return szPath;
}