Home > Back-end >  Consult on delphi7 reads the text file resources, normal delphi10.3 at the end of the code
Consult on delphi7 reads the text file resources, normal delphi10.3 at the end of the code

Time:11-05



Consult everybody, I use the same text file transfer resource file output is normal in the delphi7, appear in Delphi 10.3 at the end of the code is how to return a responsibility?

This is written in the delphi7 code
Var
Res: TResourceStream;
PostStream: TStringStream;
Buf: an array of Char [0.. 10240];
The begin
Res:=TResourceStream. Create (HInstance, 'POST_ONE', 'MyRes);
Res. The Seek (0, soFromBeginning);
Res. Read (buf, SizeOf (buf));
Writeln (buf);
Res. Free;
end;

This code is written in Delphi 10.3
Var
Res: TResourceStream;
PostStream: TStringStream;
Buf: array [0.. 10240] of AnsiChar;

The begin
Res:=TResourceStream. Create (HInstance, 'POST_ONE', 'MyRes);
Res. The Seek (0, soFromBeginning);
Res. Read (buf, SizeOf (buf));
Writeln (buf);
Res. Free;
end;

This is I use text
https://download.csdn.net/download/qq_17281823/12190563

CodePudding user response:

If the buf in 10.3: array [0.. 10240] of AnsiChar; Buf instead: array [0.. 8092] of AnsiChar; Can be normal, 8092 is Res. The Size

CodePudding user response:

Want to pass my this text file, and don't know the attachment way

CodePudding user response:

Ah, poor foundation, found that just before using a buf it is ok to assign a null value buf:=' '; Or FillMemory (@ buf [0], Length (buf), $0); Can solve the problem
  • Related