The FindClose function closes the specified search handle. The FindFirstFile and FindNextFile functions use the search handle to locate files with names that match a given name.
BOOL FindClose( HANDLE hFindFile )
If the function succeeds, return true; else return false.
EX1
int FindClose_ex1() { // case1: List all file under c: string strPath = "c:\\*.*"; FindClose_dir(strPath); return 1; } // a DOS dir command // can type into ScriptWindow "dir c:\*.*", for example. // void FindClose_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, FindNextFile
origin.h