void CCSIFTDlg::OnButtonBrows() { // TODO: Add your control notification handler code here UpdateData(TRUE); // m_edtReturnCode.SetWindowText(_T("")); m_edtFolder.SetWindowText(_T("")); BROWSEINFO bi = { 0 }; bi.hwndOwner = m_hWnd; bi.ulFlags = BIF_RETURNONLYFSDIRS; // if (m_bEditBox) if (TRUE)//是否添加显示框 bi.ulFlags |= BIF_EDITBOX; bi.ulFlags |= BIF_NONEWFOLDERBUTTON; // int nRootFolder = m_nCsidl[m_nRootIndex].nCsidl; int nRootFolder = CSIDL_DESKTOP;//选择初始文件路径 LPITEMIDLIST pidlRoot = NULL; if (SUCCEEDED(SHGetSpecialFolderLocation(m_hWnd, nRootFolder, &pidlRoot))) bi.pidlRoot = pidlRoot; LPITEMIDLIST pidl = SHBrowseForFolder(&bi); BOOL bRet = FALSE; TCHAR szFolder[MAX_PATH*2] = { _T('/0') }; if (pidl) { if (SHGetPathFromIDList(pidl, szFolder)) { bRet = TRUE; } IMalloc *pMalloc = NULL; if (SUCCEEDED(SHGetMalloc(&pMalloc)) && pMalloc) { pMalloc->Free(pidl); pMalloc->Release(); } } // m_edtReturnCode.SetWindowText(bRet ? _T("TRUE") : _T("FALSE")); m_strGCPFolder = szFolder; m_edtFolder.SetWindowText(m_strGCPFolder.c_str()); }