/*
查询文件,返回CStringList
*/
void FindFileInDir(CString szPath, CStringList& m_List)
{
//CStringList m_List; //可以用vector来取代
WIN32_FIND_DATA FindData;//查找文件必须的变量
HANDLE hFile;
szPath += "\\*";
hFile = FindFirstFile((LPCSTR)szPath, &FindData);
if(hFile == INVALID_HANDLE_VALUE)
{
return;
}
szPath.Delete (szPath.GetLength()-2,2);
m_List.AddTail(szPath);
do
{
if(strcmp(FindData.cFileName, ".") && strcmp(FindData.cFileName, "..") )
{
if(FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
CString s = szPath;
s +="\\";
s += FindData.cFileName;
FindFileInDir(s,m_List);
}
else
{
CString s=szPath;
s += "\\";
s += FindData.cFileName;
m_List.AddTail(s);
}
}
}while(FindNextFile(hFile, &FindData));
FindClose(hFile);
}