Determine the size of a file without opening it

USES
SysUtils;
...

FUNCTION FileSizeByName(CONST AFile: STRING): integer;
VAR
sr: TSearchRec;
BEGIN
IF (Pos(AFile, ’ * ’) <> 0) OR (Pos(AFile, ’?’) <> 0) OR
(FindFirst(AFile, faAnyFile, sr) <> 0)
THEN result := 1
//file was not found
ELSE result := sr.Size;
END;