Hola, yo lo he resuelto así:
Código Delphi
[-]
cPath := Trim(F_Main.DirectoryEdit1.Text) + '\';
Contar(cPath);
procedure Contar(SPath: string);
var R : TSearchRec;
Busq, nArchivos: Integer;
begin
nArchivos := 0;
if not DirectoryExists(SPath) then begin
Application.MessageBox(PChar('No existe la ruta: ' + SPath), 'Error', MB_ICONERROR);
Exit;
end;
Busq := FindFirst(SPath + '*.*', FaAnyfile, R);
while Busq = 0 do begin
if (R.Attr and faVolumeId <> faVolumeID) and (R.Name <> '.') and (R.Name <> '..') then begin
if (R.Attr <> faVolumeID) and (R.Attr and faDirectory <> faDirectory) then begin
Inc(nArchivos);
end;
end;
Busq := FindNext(R);
end;
SysUtils.FindClose(R);
end;
Lo que a mi me fallaba era la barra de directorio al final de la variable de la ruta pasada como parámetro. Ahora me da el número exacto de archivos en un directorio. Sólo me cuenta los archivos, no los directorios.
Espero que te sirva.
Un saludo.