Wop!
Mezclando tu algoritmo con el de trucomanía...
Código Delphi
[-]
function CuentaArchivos(path: AnsiString): Integer;
var
srRes : TSearchRec;
iFound : Integer;
begin
if path[Length(path)] <> '\' then
path := path +'\';
iFound := FindFirst(path+'*.*', faAnyFile-faDirectory, srRes);
Result := 0;
while iFound = 0 do
begin
if ( srRes.Name <> '.' ) and ( srRes.Name <> '..' ) and ( srRes.Name <> '' ) then
Inc(Result);
iFound := FindNext(srRes);
end;
FindClose( srRes );
end;
Si te fijas, he quitado la parte recursiva (que te podría servir si quieres contar los archivos que hay en subcarpetas) y, en lugar de añadir los nombre a una stringlist, los he contado