- //来自最近的一个程序,主体部分也是网上找的
- void CXBETaskDlg::OnButtonSetBaseDownPath()
- {
- // TODO: Add your control notification handler code here
- BROWSEINFO bi;
- TCHAR szDisplayName[MAX_PATH];
- LPITEMIDLIST pidl;
- LPMALLOC pMalloc = NULL;
- RtlZeroMemory(&bi, sizeof(bi));
- bi.hwndOwner = GetSafeHwnd();
- bi.pszDisplayName = szDisplayName;
- bi.lpszTitle = _T("请选择目录");
- bi.ulFlags = BIF_RETURNONLYFSDIRS;
- pidl = SHBrowseForFolder(&bi);
- if (pidl)
- {
- SHGetPathFromIDList(pidl, szDisplayName); //Set the directory name.
- strTaskBaseDir = szDisplayName; // strTaskBaseDir 是一个全局的CString
- SetDlgItemText(IDC_EDIT_BASEDOWNPATH, strTaskBaseDir);
- }
- // AfxMessageBox(strTaskBaseDir);
- }
SHBrowseForFolder的例子[SH]
最新推荐文章于 2021-08-27 15:50:32 发布