The FindNextFile function continues a file search from a previous call to the FindFirstFile function.
BOOL FindNextFile( HANDLE hFindFile, WIN32_FIND_DATAA * lpFindFileData )
If the function succeeds, return true; else return false.
EX1
int FindNextFile_ex1() { // case1: List all file under c: string strPath = "c:\\*.*"; dir(strPath); return 1; } // a DOS dir command // can type into ScriptWindow "dir c:\*.*", for example. // void dir(string strFile) { WIN32_FIND_DATAA find; HANDLE hFile; //out_str(strFile); int nCount = 0; if((hFile=FindFirstFile(strFile,&find)) != INVALID_HANDLE_VALUE) { out_str(find.cFileName); nCount++; while(FindNextFile(hFile,&find)) { out_str(find.cFileName); nCount++; } printf("%d files found\n",nCount); FindClose(hFile); // must close the handle } else printf("%s: file(s) not found\n",strFile); }
FindFirstFile, FindClose
origin.h