When running new releases of my installer I would like to make a backup of an existing installation by adding files into a ZIP archive.
Currently, I am able to make a backup of an existing installation by coping the files to my Backup
destination. A simplified version of the method I use is as follows:
[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;
I would appreciate any ideas how I can zip instead?
I used TLama's suggestion and created my own DLL in Delphi (XE3) that zips a folder.
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.