接上:
uses dialogs;
var
f:file of byte;
size:longint;
s:string;
y:integer;
begin
if opendialog1.execute then //指定文件名
begin
Assignfile(f,opendialog1.filename);
reset(f);
size:=filesize(f);
s:='file size in bytes:'+inttostr(size); //显示文件大小
y:=10;
canvas.textout(5,y,s);
y:=y+canvas.textheight(s)+5;
s:='seeking halfway into file...';
canvas.textout(5,y,s);
y:=y+canvas.textheight(s)+5;
seek(f,size div 2);
s:='Position is now '+inttostr(filepos(f));
canvas.textout(5,y,s);
closefile(f);
end;
end.