分类: C/C++
2008-08-05 13:53:41
void CTestBrowseDlg::OnBrowse() { CString str; BROWSEINFO bi; char name[MAX_PATH]; ZeroMemory(&bi,sizeof(BROWSEINFO)); bi.hwndOwner=GetSafeHwnd(); bi.pszDisplayName=name; bi.lpszTitle="Select folder"; bi.ulFlags=BIF_USENEWUI; LPITEMIDLIST idl=SHBrowseForFolder(&bi); if(idl==NULL) return; SHGetPathFromIDList(idl,str.GetBuffer(MAX_PATH)); str.ReleaseBuffer(); m_Path=str; if(str.GetAt(str.GetLength()-1)!=''\\'') m_Path ="\\"; UpdateData(FALSE); }本工程在VC 7.0 WindowsXP中调试通过。