选择路径对话框

CString CPublicFuncs::GetFilePath(CString title)
{
    CString   strFilePath;   
    TCHAR   pszBuffer[_MAX_PATH];   
    BROWSEINFO   bi;   LPITEMIDLIST   pidl;   
    bi.hwndOwner   
=   NULL;   
    bi.pidlRoot   
=   NULL;   
    bi.pszDisplayName   
=   pszBuffer;   
    bi.lpszTitle   
=   title;   
    bi.ulFlags   
=   BIF_RETURNFSANCESTORS   |   BIF_RETURNONLYFSDIRS;   
    bi.lpfn   
=   NULL;   
    bi.lParam   
=   0;   
    
if((pidl   =   SHBrowseForFolder(&bi))   !=   NULL)   
    
{   
        
if(SHGetPathFromIDList(pidl,   pszBuffer))   
        
{   
            CString   strTemp(pszBuffer);       strFilePath   
=   strTemp;   
            
if   (strFilePath.GetLength()   <=   1)     
            
{   
            }
   
            
else   if   (strFilePath.Right(1)   !=   _T("\\"))     
                strFilePath   
+=   _T("\\");   
        }
   
    }
   
    
return strFilePath;
}
原文地址:https://www.cnblogs.com/strinkbug/p/743226.html