我们最近对一个使用 INNO 脚本安装的应用程序进行了重大重组。
不幸的是,该应用程序需要某些文件在不同版本之间保持不变。
更不幸的是,这些文件的位置在这次重组期间发生了变化。
最不幸的是,现在由我来制作一个 INNO 脚本片段,它将查看这些文件是否存在,并将它们从以前的位置移动到新位置。
是否可以让 INNO 脚本检查文件(与 INNO 脚本本身无关)是否存在,如果存在,则在安装完成之前/之后将它们移动到新位置?
编辑1:为了清晰起见
我说这些文件与INNO脚本无关,因为它们是用户生成的内容。
对的,这是可能的。下面的代码是复制和删除(而不是原始移动或重命名)。
Use the [Code]
部分来实现这个逻辑。
有关的文档支持的功能 https://jrsoftware.org/ishelp/index.php?topic=scriptfunctions和您可以处理的事件 https://jrsoftware.org/ishelp/index.php?topic=scriptevents还不错。
如何对开始安装做出反应:
procedure CurStepChanged(CurStep: TSetupStep);
begin
case CurStep of
ssInstall:
begin
{ will be executed just before the actual installation starts }
end;
ssPostInstall:
begin
{ will be executed just after the actual installation finishes }
end;
end;
end;
如何知道文件是否存在
if FileExists(FileName) then
begin
{ do something when the file exists }
end;
复制文件(覆盖现有文件)
if not FileCopy(ExistingFileName, NewFileName: String, false) then
begin
{ handle copy error }
end;
删除文件
if not DeleteFile(FileName) then
begin
{ handle delete error }
end;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)