Board index » cppbuilder » Re: find .exe's
Remy Lebeau (TeamB)
![]() CBuilder Developer |
Re: find .exe's2007-10-31 04:48:56 AM cppbuilder109 "mataus" < XXXX@XXXXX.COM >wrote in message QuoteMy code is: will drastically slow down the code as well. Try something more like the following instead: int MsgUpdateCnt = 0; void __fastcall TForm1::RecursiveSearch(const AnsiString &p_sPath) { MsgUpdateCnt = 0; InternalRecursiveSearch(p_sPath); } void __fastcall TForm1::InternalRecursiveSearch(const AnsiString &p_sPath) { AnsiString sPath = IncludeTrailingBackslash(p_sPath); WIN32_FIND_DATA fdFindFileData; HANDLE hFileSearching = FindFirstFile((sPath + "*").c_str(), &fdFindFileData); if( hFileSearching != INVALID_HANDLE_VALUE ) { do { if( FILE_ATTRIBUTE_DIRECTORY & fdFindFileData.dwFileAttributes ) { if( (strcmp(fdFindFileData.cFileName, ".") != 0) && (strcmp(fdFindFileData.cFileName, "..") != 0) ) InternalRecursiveSearch(sPath + fdFindFileData.cFileName); } else { AnsiString szFile = fdFindFileData.cFileName; if( AnsiSameText(ExtractFileExt(szFile), ".exe") ) Memo1->Lines->Add(szFile); } if( ++MsgUpdateCnt == 100 ) { Application->ProcessMessages(); MsgUpdateCnt = 0; } } while( FindNextFile(hFileSearching, &fdFindFileData) ); FindClose(hFileSearching); } } Gambit |