🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #999

Re: find .exe's

#999
From: Remy Lebeau (TeamB)
Date: Tue, 30 Oct 2007 20:48
61 lines
2835 bytes
"mataus" <mataus@gmail.com> wrote in message 
news:4727891b$1@newsgroups.borland.com...

> My code is:

For every directory, you are checking for a file extension.  Don't do that. 
You are also calling ProcessMessages() on every iteration of the loop, which 
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 
Technical Details
Message-ID: <472799b1$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4727891b$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,52a2861022dfbb0b
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <4727891b$1@newsgroups.borland.com>
Subject: Re: find .exe's
Date: Tue, 30 Oct 2007 13:48:56 -0700
Lines: 63
Organization: Lebeau Software
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 207.178.157.90
Message-ID: <472799b1$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1193777585 207.178.157.90 (30 Oct 2007 13:53:05 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail