

請教大家,我用同一個文本檔案轉的資源檔案在delphi7中輸出正常,在delphi 10.3中出現末尾亂碼是怎么回事呢?
這是在delphi7中寫的代碼
var
Res: TResourceStream;
postStream: TStringStream;
buf: array [0 .. 10240] of Char;
begin
Res := TResourceStream.Create(HInstance, 'POST_ONE', 'MyRes');
Res.Seek(0, soFromBeginning);
Res.Read(buf, SizeOf(buf));
Writeln(buf);
Res.Free;
end;
這是在delphi 10.3中寫的代碼
var
Res: TResourceStream;
postStream: TStringStream;
buf: array [0 .. 10240] of AnsiChar;
begin
Res := TResourceStream.Create(HInstance, 'POST_ONE', 'MyRes');
Res.Seek(0, soFromBeginning);
Res.Read(buf, SizeOf(buf));
Writeln(buf);
Res.Free;
end;
這個是我使用的文本
https://download.csdn.net/download/qq_17281823/12190563
uj5u.com熱心網友回復:
如果把10.3中的 buf: array [0 .. 10240] of AnsiChar;改為 buf: array [0 .. 8092] of AnsiChar;就可以正常,8092是Res.Sizeuj5u.com熱心網友回復:
想把我的呢個文本檔案傳上來,又不知道傳附件的方法
uj5u.com熱心網友回復:
哎,基礎太差,剛才發現使用前個buf賦個空值就可以了 buf:='';或FillMemory(@buf[0],Length(buf), $0);都可以解決問題轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/15960.html
標籤:非技術區
上一篇:從EXCEL表中獲取圖片-200
