Delphi Record To Stream

2021-06-19 04:05

阅读:355

标签:use   size   string   begin   fuser   fuse   RoCE   click   info   

type
  TUserInfo = record
  sUserId,sUserName:String;
  iUserCount:integer;
end;

procedure TForm1.Button1Click(Sender: TObject);
var fStream:TMemoryStream;
  fUserRec,sUserDD:TUserInfo;
  sDataText:String;
begin
  try
    fUserRec.sUserId := UserId;
    fUserRec.sUserName := 张三峰;
    fUserRec.iUserCount := 9876;        
    fStream := TMemoryStream.Create;

    fStream.Write(fUserRec,SizeOf(TUserInfo));
    fStream.Position := 0;
    ///sDataText := StreamToBase64(fStream);
    //MyInfo(sDataText);
    MyInfo(IntToStr(fStream.Size));
    fStream.Read(sUserDD,sizeof(TUserInfo));
    MyInfo(sUserDD.sUserId);

  finally
    freeAndNil(fStream);
  end;
end;

 

Delphi Record To Stream

标签:use   size   string   begin   fuser   fuse   RoCE   click   info   

原文地址:https://www.cnblogs.com/wissly/p/10292699.html


评论


亲,登录后才可以留言!