vielleicht hilft Dir dieses kleine Beispiel ?
Code:
procedure TForm1.Button1Click(Sender: TObject);
var m : TMemorystream;
p : ^ byte;
bytecount : DWORD;
i : integer;
puffer : string;
begin
m := Tmemorystream.Create;
m.SetSize(5);
puffer := 'HALLO';
p := m.Memory;
bytecount := m.Size;
for i := 0 to bytecount -1 do
begin
p^ := ord ( puffer[i+1]);
inc(p);
end;
p := m.Memory;
for i := 0 to bytecount -1 do
begin
showmessage( Char(p^) + ' ' + inttostr(p^) );
inc(p);
end;
m.SaveToFile('test.txt');
m.Free;
end;