{
// TODO: Add your control notification handler code here
LPMALLOC pMalloc;
/* Gets the Shell's default allocator */
if (::SHGetMalloc(&pMalloc) == NOERROR) //獲得pMalloc
{
BROWSEINFO bi;
char pszBuffer[MAX_PATH];
LPITEMIDLIST pidl;
// Get help on BROWSEINFO struct - it's got all the bit settings.
//設定Browse的屬性
bi.hwndOwner = GetSafeHwnd();
bi.pidlRoot = NULL;
bi.pszDisplayName = pszBuffer;
bi.lpszTitle = _T( "請選擇保存的位置" ); //
bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
bi.lpfn = NULL;
bi.lParam = 0;
// This next call issues the dialog box.
if ((pidl = ::SHBrowseForFolder(&bi)) != NULL) //顯示瀏覽窗口 SHBrowseForFolder
{
if (::SHGetPathFromIDList(pidl, pszBuffer)) //把路徑存進pszBuffer中
{
// At this point pszBuffer contains the selected path */.
// Free the PIDL allocated by SHBrowseForFolder.
pMalloc->Free(pidl);
// Release the shell's allocator.
pMalloc->Release();
/************這個有什麼作用嗎?******************
RECT re;
re.bottom=100;
re.left=50;
re.right=300;
re.top=50;
InvalidateRect(&re,TRUE);//清除路徑中的上次的文字
*******************************************/
return bi.pszDisplayName;
//SetDlgItemText(IDC_PATH, bi.pszDisplayName);//填寫路徑名字
}
else
return "";
}
else
return "";
}
else
return "";
}