MFC 如何创建浏览文件夹的对话框

时间:2024-01-18 17:15:38

如何创建浏览文件夹的对话框

如何创建浏览文件夹的对话框
CString CXXXXDlg::GetOpenfolderPath()
{
BROWSEINFO bi;
ZeroMemory(&bi,sizeof(BROWSEINFO));
bi.ulFlags = 0x0040 | BIF_EDITBOX;
LPMALLOC pMalloc;
LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
CString strFolderPath = "";
char savepath[MAX_PATH];
memset(savepath,,sizeof(savepath));
if(pidl != NULL){
SHGetPathFromIDList(pidl,savepath);
strFolderPath.Format(_T("%s"), savepath);
f (SUCCEEDED(SHGetMalloc(&pMalloc))) {
pMalloc->Free(pidl);
pMalloc->Release();
}
}
return strFolderPath;
}