program dp_185013;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.Classes,
System.SysUtils;
procedure OutputBuffer( ABuffer: TBytes );
var
I: Integer;
begin
for I := low( ABuffer )
to high( ABuffer )
do
begin
write( IntToHex( ABuffer[ I ], 2 ), '
' );
if ( I + 1 - low( ABuffer ) )
mod 16 = 0
then
Writeln;
end;
Writeln;
end;
procedure Test;
var
LStream: TMemoryStream;
LBuffer: TBytes;
begin
LStream := TMemoryStream.Create;
try
// Daten in den Stream
LStream.WriteData( $02 );
LStream.WriteData( Byte( StrToInt( '
1' ) ) );
LStream.WriteData( Int32( StrToInt( '
46762' ) ) );
LStream.WriteData( $00 );
// Stream-Inhalt nach TBytes kopieren
SetLength( LBuffer, LStream.Size );
LStream.Position := 0;
LStream.
Read( LBuffer, Length( LBuffer ) );
// Ausgabe der TBytes zur Kontrolle
OutputBuffer( LBuffer );
finally
LStream.Free;
end;
end;
begin
try
Test;
except
on E:
Exception do
Writeln( E.ClassName, '
: ', E.
Message );
end;
ReadLn;
end.