{
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;
}