I use a MemoryStream to build an array of bytes that I need to send to the server. I have some questions:
1) Is there a better way to build an array of bytes than this?
2) Why does this piece of code write fiction in my memory stream?
var serial : word; MS : TMemoryStream; const somebytes : array [0..1] of byte = ($72,$72); ... begin MS := TMemoryStream.Create(); try MS.Write(somebytes[0],2); serial := $3E6C; MS.Write(serial,2); finally MS.Free; end;
Using the debugger, I see that the value $ 6F32 has been added to the stream instead of $ 3E6C.
3) If I call
MS.Position := 2;
and then I get access to PByte (MS.Memory) ^ why do I get the first byte in the stream instead of the third?
source share