gpt4 book ai didi

inno-setup - 在 Inno Setup 中逐行读取文本文件

转载 作者:行者123 更新时间:2023-12-05 02:28:59 25 4
gpt4 key购买 nike

我正在尝试使用 Inno Setup 逐行读取文本文件。

我试过这里提到的这个:https://jrsoftware.org/ispphelp/index.php?topic=fileread

function ShowLines(): Boolean;
var
list: Integer;
begin
list := FileOpen(ExpandConstant('{tmp}\file.txt'));

if !FileEof(list) then begin
try
repeat
MsgBox(FileRead(list), mbInformation, MB_OK);
until !FileEof(list);
finally
FileClose(list);
end;
end;
Result := True;
end;

但它会在 FileOpen(可能还有其他 File 函数)上给出一个未知标识符的错误。问题出在哪里?

文件小于 50kb。

最佳答案

您尝试从 Pascal Script 调用的所有函数实际上都是 preprocessor functions . Pascal 脚本没有可以按行(或任何类型的 block )读取文件的内置函数。

您可以使用 WinAPI 文件函数来实现它,例如 CreateFileReadFile .

但如果文件不是太大,你可以简单地使用内置函数LoadStringsFromFile .有关示例,请参阅 Read strings from file and give option to choose installation .

类似问题:"Unknown Identifier 'FileOpen'" when trying to detect locked file in Inno Setup code .


看到您正在读取来自 {tmp} 的文件,很可能您实际上正在读取从安装程序本身提取的临时文件。如果是这种情况,则意味着您已经在编译时获得了该文件。在这种情况下,您确实可以使用预处理器函数在编译时读取文件。

但这需要使用完全不同的语言/语法的代码。一些例子:

关于inno-setup - 在 Inno Setup 中逐行读取文本文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72395007/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com