Delphi Record To Stream
阿新 • • 發佈:2019-01-19
posit memory use click form and fin ring class
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