我这两个函数怎么调用
#include<vector>using namespace std;
void TraverseDir(CString& dir, std::vector<CString>& vec)
{
CFileFind ff;
if (dir.Right(1) != "\\")
{
dir += "\\";
}
dir+="*.*";
BOOL ret = ff.FindFile(dir);
while (ret)
{
ret = ff.FindNextFile();
if (ret != 0)
{if(ff.IsDirectory()&& !ff.IsDots())
{
CString path = ff.GetFilePath();
TraverseDir(path,vec);
}
else if (!ff.IsDirectory() && !ff.IsDots())
{
CString name=ff.GetFileName();
CString path = ff.GetFilePath();
vec.push_back(path);
}
}
}
}
用到第二个里面去:
void CmmmmDlg::OnBnClickedButton1()
{
CString m_path;
TCHAR pszPath[MAX_PATH];
BROWSEINFO bi;
bi.hwndOwner = this->GetSafeHwnd();
bi.pidlRoot = NULL;
bi.pszDisplayName = NULL;
bi.lpszTitle = TEXT("请选择文件夹");
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT;
bi.lpfn = NULL;
bi.lParam = 0;
bi.iImage = 0;
LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
if (pidl == NULL)
{
return;
}
if (SHGetPathFromIDList(pidl, pszPath))
{
//AfxMessageBox(pszPath);
m_path = pszPath;
}
}
[ 本帖最后由 ws1328678556 于 2015-5-14 13:47 编辑 ]