在已编译的Inno Setup安装程序中修改配置文件(每个下载的可执行文件的自定义配置文件) [英] Modify configuration file in compiled Inno Setup installer (custom configuration file for each downloaded executable)

查看:766
本文介绍了在已编译的Inno Setup安装程序中修改配置文件(每个下载的可执行文件的自定义配置文件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个项目上工作,该项目需要一种独特的操作方法,该方法需要使用不同的配置文件(包含每次​​下载的唯一标识号)更新Windows Installer exe(使用Inno Setup打包).

I am working on a project which needs a unique method of operation which requires a windows installer exe (packaged using Inno Setup) to be updated with different configuration file containing a unique identification number for every downloads.

该项目本身是一个基于Web的网站,我为此在Apache和Linux上使用PHP.

The project itself is a web based for which I am using PHP on Apache and on Linux.

安装程序包含Windows二进制可执行文件和config.ini文件.每当文件准备下载时,我只需要编辑config.ini文件.更新只是增加计数器.

The installer contains a Windows binary executable file and config.ini file. I just need to edit the config.ini file every time the file is to be made ready for download. The updates are simply incremented counter.

我在编辑Windows中创建的Inno Setup打包文件并在Linux服务器中进行编辑时,没有找到解决方法.

I am not finding a direction to approach as I am looking at editing a Inno Setup packaged file created in Windows to be edited in a Linux server.

任何人都可以指出一些想法来实现这一目标.

Can anyone point me towards some ideas to achieve this please.

谢谢,
Sk

Thanks,
Sk

推荐答案

只需将配置文件未经压缩就存储到安装程序中即可轻松进行修改.使用 nocompression标志.您还必须使用 dontverifychecksum标志,否则安装时,安装程​​序会认为修改后的文件已损坏.

Just store the configuration file to the installer uncompressed to allow easy modification. Use nocompression flag. You also have to use dontverifychecksum flag, otherwise the installer will consider the modified file as corrupted, when installing.

[Files]
Source: "config.ini"; DestDir: "{app}"; Flags: nocompression dontverifychecksum

您也不能修改文件长度.因此,您需要在文件中保留足够的空间用于更大的数字,例如:

You also cannot modify file length. So you need to reserve enough space in the file for larger numbers, like:

[Section]
Counter=?????

要使用PHP修改安装程序,您现在可以执行以下操作:

To modify the installer with PHP, you can now do:

$counter = $_GET["counter"];
$filename = "mysetup.exe";
$contents = file_get_contents($filename);
$mask = "?????";
$prefix = "Counter=";
$replace = $prefix . $mask;
$p = strpos($contents, $replace);
if ($p !== false)
{
    $s = $prefix . str_pad($counter, strlen($mask), "0", STR_PAD_LEFT);
    $contents = substr($contents, 0, $p) . $s . substr($contents, $p + strlen($replace));
    file_put_contents($filename, $contents); // or feed directly to the output stream
}


如果您对安装程序进行了签名(应该这样做),则必须在对其进行修改后对其进行签名.


If you sign the installer (you should), you have to sign it after modifying it.

或参见在下载时将用户特定的数据嵌入到经过Authenticode签名的安装程序中

这篇关于在已编译的Inno Setup安装程序中修改配置文件(每个下载的可执行文件的自定义配置文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆