// save the image file name VectorImageNames.push_back( strName ); } }
// loop through to add all of them to our vector while (bRC) { bRC = ::FindNextFile(hFind, &FindFileData); if (bRC) { // filter off the system files and directories if (!(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && !(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) && !(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) && !(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_TEMPORARY)) { // test file extension strName = FindFileData.cFileName; strExt = strName.Right(3);
if(FindType(strExt)){ // save the image file name VectorImageNames.push_back(strName); } } } else { DWORD err = ::GetLastError(); if (err != ERROR_NO_MORE_FILES) { LPVOID msg; ::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&msg, 0, NULL); MessageBox((LPTSTR)msg, _T("fileload error"), MB_OK|MB_ICONSTOP); ::LocalFree(msg); ::FindClose(hFind); return FALSE; } } } // end of while loop
// close the search handle ::FindClose(hFind);
// update the names, if any if ( !VectorImageNames.empty() ) { // reset the image name vector m_vtImageName->clear(); *m_vtImageName = VectorImageNames; return TRUE; } else { m_vtImageName->clear(); return TRUE; }