函數
int FolderBrowser( char path[MAX_PATH], char * title = " 請選擇: " )
{
BROWSEINFO bi;
ITEMIDLIST * pidl;
bi.hwndOwner = NULL;
bi.pidlRoot = NULL;
bi.pszDisplayName = path;
bi.lpszTitle = title;
bi.ulFlags = BIF_EDITBOX;
bi.lpfn = NULL;
bi.lParam = 0 ;
bi.iImage = 0 ;
pidl = SHBrowseForFolder( & bi);
return (pidl && SHGetPathFromIDList(pidl,path));
}
調用方法:
void CDownloadFileDlg::OnButton1()
{
UpdateData();
char buf[MAX_PATH] = { 0 };
if (FolderBrowser(buf))
{
m_path = buf;
UpdateData(FALSE);
}
}