2014年6月15日 星期日

[BCB] FindFirst 好範例

void __fastcall FindFile(FileList, sStartDir, sFileMask)
{
    TSearchRec SR;  //TSearchRec defines file information
    bool IsFound;

    // 0:a file was successfully located
    IsFound = (FindFirst(sStartDir+sFileMask, faAnyFile-faDirectory, SR) == 0);
    while (IsFound)
    {
        FileList->Add(sStartDir + SR.Name);
        IsFound = (FindNext(SR) == 0);
    }
    FindClose(SR);
}