如何在 Inno Setup 中从 INF 文件读取自定义值?

发布于 2024-08-17 08:16:30 字数 122 浏览 3 评论 0 原文

使用 Inno Setup 创建的安装程序可以通过 /LOADINF 选项读取 INI 文件。是否可以通过这个INI文件读取自定义变量?是否有函数可以获取此选项给出的 INI 文件的名称? (然后可以使用 INI 实用程序函数。)

Setup programs created with Inno Setup could read an INI file through /LOADINF option. Is it possible to read custom variables through this INI file? Is there a function to get the name of the INI file given with this option? (Then it is possible with the INI utility functions.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦里南柯 2024-08-24 08:16:30

该代码

ExpandConstant('{param:LoadInf}')

从命令行参数提供文件 INI 文件名。

如果 INF 文件位于安装文件夹中,请使用此代码

AddBackslash(ExpandConstant('{src}')) + ExpandConstant('{param:LoadInf}');

The code

ExpandConstant('{param:LoadInf}')

provides the file INI file name from the command line parameters.

Use this code if the INF file is in the setup folder

AddBackslash(ExpandConstant('{src}')) + ExpandConstant('{param:LoadInf}');
少年亿悲伤 2024-08-24 08:16:30

我们只需使用 ParamStr(i) 函数迭代命令行参数,并查找以“/LOADINF=”开头的参数,然后从那里提取文件名。

最初我们遇到的一个问题是文件名可能是相对路径描述符(例如只是文件名)。但是,如果您使用压缩,则当前工作目录将是 %TEMP% 文件夹中的某个子文件夹,而不是 setup.exe 所在的目录。因此,您应该确保检测到这一点,并在必要时在给定的文件名前面添加 AddBackslash(ExpandConstant('{src}'))

We simply iterate over the commandline arguments using the ParamStr(i) function and look for an argument starting with "/LOADINF=" and then extract the file name from there.

One gotcha that got us initially was that the file name might be a relative path descriptor (e.g. just the file name). However, if you use compression then the current working directory will be some sub-folder in your %TEMP% folder rather than the directory where your setup.exe is. You should therefore make sure to detect this and prepend the given file name with AddBackslash(ExpandConstant('{src}')) if necessary.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文