Home > Back-end >  A DCU function interface, write the data parameter is Pansichar, how to write an Integer value in it
A DCU function interface, write the data parameter is Pansichar, how to write an Integer value in it

Time:10-02


DCU interface is JFWrite (Buffer: PAnsiChar; Addr, Length: Integer);
The DCU, no source code, interface can't change

I need to write a data length in

Size: Integer;
S: a String;
Mem: Tmemorystream;
S:='Hi, I Love the Delphi! ';
Mem:=Tmemorystream. Create;
Mem. WriteBuffer (S [1], Length (S));

Size:=Mem. Size;

JFWrite (PAnsiChar (@ the Size), 100, SizeOf (Integer)); To write the data length, can't write in. In the several methods are not

Mem. Free;

CodePudding user response:

According to your information, your writing is no problem, the Size of 4 bytes data written to a 100 address,

CodePudding user response:

Don't understand what do you want to do,
If a length to write in the byte stream the beginning?
Size: Int64;
Mem: Tmemorystream;

S:='Hi, I Love the Delphi! ';
Mem:=Tmemorystream. Create;
Mem. WriteBuffer (0, SizeOf (Int64));
Mem. WriteBuffer (S [1], Length (S));
Size:=Mem. Size;
Mem. Position:=0;
Mem. WriteBuffer (Size, SizeOf (Int64));
  • Related