Inno Setup - 在更新之前压缩本地文件

时间:2013-11-07 09:24:52

标签: inno-setup

运行我的安装程序的新版本时,我想通过将文件添加到zip-archive中来备份现有安装。

目前,我可以通过将文件复制到备份目标来备份现有安装。我使用的方法的简化版本如下:

[Files]
;Copy the contents of Bin folder to Backup folder. Skip if files don’t exist. 
Source: {app}\Bin\*;  DestDir: {app}\Backup\; Flags: createallsubdirs external recursesubdirs uninsneveruninstall skipifsourcedoesntexist;

我很欣赏任何可以拉链的想法吗?

2 个答案:

答案 0 :(得分:2)

你可能想看看LOGAN ISSI:http://members.home.nl/albartus/inno/index.html有一些与它捆绑在一起的工具。

另一种方法是包含一个批处理文件,该文件将执行备份步骤,然后在完成后将其自行删除。

结帐此帖:Batch script to zip all the files without the parent folder

但是由于许可,您不允许将rar.dll与您的应用捆绑在一起,所以只需应用此方法,但使用可重新分发的包/ dll。

如果你可以使用VBScript编写一个简单的包装器,你也可以使用zip压缩内置的窗口。

了解你:Can Windows' built-in ZIP compression be scripted?

答案 1 :(得分:2)

感谢用户2976811为您提供替代方案。我使用了TO Lama的建议,并在Delphi(XE3)中创建了我自己的DLL,它压缩了一个文件夹。

library MyZipLib;
uses
  Winapi.Windows,
  System.SysUtils,
  System.Zip;

{$R *.res}

function ZipCompressFolder(SourcePath, DestinationPath, ArchiveName : PChar): boolean; stdcall;
begin
  //If source folder does not exist then exit without error.
  if not DirectoryExists(SourcePath) then
  begin
    result := true;
    exit;
  end;

  try
    result := false;

    //Make sure destination path exists
    ForceDirectories(DestinationPath);
    TZipFile.ZipDirectoryContents(IncludeTrailingPathDelimiter(DestinationPath) + ArchiveName, SourcePath);
    result := true;
  except
    on E : Exception do MessageBox(0, PChar('Error calling function ZipCompressFolder@MyZipLib.dll with message: ' + E.Message + #13#10 + 'Source: ' + SourcePath + #13#10 + 'Dest: ' + DestinationPath+ #13#10 + 'Archive: ' + ArchiveName), 'MyZipLib.dll Error', MB_OK);
  end;
end;

exports ZipCompressFolder;
begin
end.
相关问题