MFC 文件夹选择对话框
Posted 平楚荒烟
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MFC 文件夹选择对话框相关的知识,希望对你有一定的参考价值。
CString setSavePath() { CString strPath = _T(""); HRESULT hr; LPITEMIDLIST pItemList; BROWSEINFO browseinfo; TCHAR path[MAX_PATH]; hr = ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); if (FAILED(hr)) { TRACE("CoInitEx failed: %x\n", hr); return strPath; } IMalloc *pMalloc = NULL; hr = SHGetMalloc(&pMalloc); if (FAILED(hr)) { TRACE("Can‘t retrieve system‘s IMalloc interface: %x\n", hr); return strPath; } ENSURE(pMalloc); memset(&browseinfo, 0, sizeof(BROWSEINFO)); CString strCaption; browseinfo.hwndOwner = GetSafeHwnd(); browseinfo.pszDisplayName = path; browseinfo.ulFlags = BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS; strCaption.LoadString(IDS_SAVEPATH_CONFIG); browseinfo.lpszTitle = strCaption; pItemList = ::SHBrowseForFolder(&browseinfo); if (pItemList) { // Behold the elegance of CStrBuf! ::SHGetPathFromIDList(pItemList, CStrBuf(strPath, MAX_PATH)); pMalloc->Free(pItemList); UpdateData(FALSE); } pMalloc->Release(); pMalloc = NULL; ::CoUninitialize(); return strPath; }
以上是关于MFC 文件夹选择对话框的主要内容,如果未能解决你的问题,请参考以下文章