给你一段简单的例子。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
ListBox1: TListBox;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
type
sz1=array[1..10] of char;
sz2=array[1..20] of char;
sz3=array[1..14] of char;
jllx1=record
bsf,nian,yue,ri:byte;
zjls:longint;
zdgs:word;
qt:sz2;
end;
jllx2=record
zdm:sz1;
wz1:byte;
zdlx:char;
wz2:longint;
zdkd,xsw:byte;
qt:sz3;
end;
var
infile:file;
br,i,j:integer;
fname,sss:String;
txx:jllx1;
zdb:jllx2;
begin
fname:='c:/abc.dbf';
assignfile(infile,fname);
reset(infile,1);
blockread(infile,txx,sizeof(txx),br);
listbox1.Items.Clear;
j:=round((txx.zdgs-1)/32-1);
for i:=1 to j do begin
blockread(infile,zdb,sizeof(zdb),br);
sss:=zdb.zdlx+' | '+inttostr(zdb.zdkd)+' | '+inttostr(zdb.xsw)+' '+zdb.zdm;
listbox1.Items.Add(sss);
end;
closefile(infile);
end;
end.