Declaration: ScanFolder(FileMask: string; IncludeSubDirs: boolean; SL: TStringList): integer;
Scans the disk for files whose name match the parameter FileMask. The search starts at the path specified by FileMask and recursively searches all subdirectories if the parameter IncludeSubDirs is TRUE. All filenames which match the FileMask are appended to the string list SL. Please note that you have to explicitly clear the string list if you do not want to append the scanned files names to the existing strings in the string list. The parameter FileMask may contains wildcards in the filename and extension but not in the path.

The returned filenames contain paths in the same format as specified in the parameter FileMask. If FileMask is a full path, the filenames in the string list also contain the full paths, if FileMask specifies a relative path the returned files are also relative.

The function returns the number of found files. A zero value indicates that either there is no file matching the file mask, or the FileMask parameter is invalid, or points to a non-existing directory.