//读取文件函数
function ReadFile1(FileName:String):boolean;
var
sFileName: string;
f: TfileStream;
ED_Data: array[0..2048] of char;
lRet: integer;
lOffset: Longint;
lOrigin: Word;
i,count:integer;
begin
sFileName:=form1.opendialog1.FileName;
f := TfileStream.Create(sFileName,fmOpenRead);
try
f.Seek(lOffset,lOrigin); //文件定位,从lOrigin开始移动lOffset
begin
lRet := f.Read(f,count); //lRet为实际读到的字节数,ED_Data为读到的内容
form1.Memo2.Lines.LoadFromStream(f);
j:=f.size div 1024; //计算文件一共有多少个包
// form1.suimemo1.Text:=strtohexstr(ed_data[count]);
Application.ProcessMessages;
begin
for i:=0 to j do
begin
form1.Label1.Caption:='正在读取第 '+inttostr(i)+' 包 ';
form1.Memo1.Text:=form1.Memo1.Text+ midstr(strtohex(form1.Memo2.text),2048*i,2048)+' ';
//Progressbar进度栏
form1.ProgressBar1.Max :=j;
form1.ProgressBar1.Min:=0;
form1.ProgressBar1.Position := i;
Application.ProcessMessages;
end;
// form1.memo2.clear;
showmessage('成功读取'+inttostr(i)+'个包');
Application.ProcessMessages;
end;
end;
finally
FreeAndNil(f);
Application.ProcessMessages;
end;
end;
1