----赖格英-----

记忆不好了,记录工作中的点点滴滴....

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
procedure TForm23.Button4Click(Sender: TObject);
var
pstr:Pchar;
mestr,Str1:string;
FS:TFilestream;
meint,PoStr,I,LenStr:integer;
Fpos:Int64;
TT,IsDay:Boolean;
Liststr:TStringList;
begin
  if not Self.OpenDialog1.Execute then Exit;
  FS:=TFileStream.Create(Self.OpenDialog1.FileName,fmOpenRead);
  meint:=1024;
  getmem(pstr,meint);//申请字符指针内存
  TT :=False;
  I:=0;
  Liststr :=TStringList.Create;
  try
    while not TT do
    begin
      Fpos:=I*meint;
      FS.Position:=Fpos;
      fs.Readbuffer(pstr^,meint);
      if True then
      
      mestr:=pstr;
      SetLength(mestr,meint);
      Liststr.Text:=mestr;
      if i=0 then Self.Memo1.Text:=Liststr.Text;
      Self.Edit1.Text :=IntToStr(Liststr.Count);
      i:=i+1;
      if i>2 then TT :=True;
    end;
  finally
    freemem(Pstr);//释放内存
    FS.Free;//释放流
    Liststr.Free;
  end;
end;

 

posted on 2016-11-17 16:33  向北方  阅读(3592)  评论(0编辑  收藏  举报