#define VerInfoTxt "004" [_ISTool] EnableISX=false [Setup] OutputBaseFilename=HCMQTT_v{#VerInfoTxt} AppVerName=Harpoon Classic MQTT Link ({#VerInfoTxt}) AppVersion={#VerInfoTxt} AppCopyright=Copyright © 2020 TGP Enterprises, Inc. AppPublisher=HarpGamer AppPublisherURL=https://harpgamer.com AppId=HCMQTT AppName=Harpoon Classic MQTT Link VersionInfoCompany=TGP Enterprises, Inc. VersionInfoCopyright=Copyright 2020 VersionInfoProductName=Harpoon Classic MQTT Link VersionInfoTextVersion={#VerInfoTxt} VersionInfoVersion={#VerInfoTxt} MinVersion=0,6.1.7600 PrivilegesRequired=none ChangesAssociations=false DisableProgramGroupPage=false DefaultDirName={reg:HKCU\Software\Matrix Games\HCE\Options\BattlesetPath,|{sd}\Matrix Games\HUCE}\ExportDLLs AppendDefaultDirName=false UsePreviousAppDir=true DirExistsWarning=false AllowUNCPath=false InfoBeforeFile=HCMQTT.txt DisableStartupPrompt=true DisableReadyMemo=false DisableReadyPage=false AlwaysShowDirOnReadyPage=true AlwaysShowGroupOnReadyPage=true ;WizardImageFile=..\Standard (large).bmp ;WizardSmallImageFile=..\Standard (small) 11.bmp ;SetupIconFile=..\BSCheck\src\ShipPlaneSub.ico SignToolRetryCount=2 SignToolRetryDelay=750 SignToolMinimumTimeBetween=5000 SignTool=TGPStandard Compression=lzma/ultra64 SolidCompression=yes TouchDate=current TouchTime=00:00:00 [Files] Source: C:\Games\HC\ExportDLLs\HCMQTTLink.dll; DestDir: {app}; Flags: ignoreversion touch signonce; BeforeInstall: BackupFile Source: .\HCMQTT.txt; DestDir: {app}; Flags: ignoreversion touch; BeforeInstall: BackupFile Source: .\License.txt; DestDir: {app}; Flags: ignoreversion touch; BeforeInstall: BackupFile Source: C:\Games\HC\ExportDLLs\HCMQTT\HCMQTTSender.exe; DestDir: {app}\HCMQTT; Flags: ignoreversion touch signonce; BeforeInstall: BackupFile Source: C:\Games\HC\ExportDLLs\HCMQTT\libeay32.dll; DestDir: {app}\HCMQTT; Flags: ignoreversion touch signonce; BeforeInstall: BackupFile Source: C:\Games\HC\ExportDLLs\HCMQTT\ssleay32.dll; DestDir: {app}\HCMQTT; Flags: ignoreversion touch signonce; BeforeInstall: BackupFile [ThirdParty] CompileLogMethod=append [Code] const GetFileExInfoStandard = $0; type FILETIME = record LowDateTime: DWORD; HighDateTime: DWORD; end; WIN32_FILE_ATTRIBUTE_DATA = record FileAttributes: DWORD; CreationTime: FILETIME; LastAccessTime: FILETIME; LastWriteTime: FILETIME; FileSizeHigh: DWORD; FileSizeLow: DWORD; end; SYSTEMTIME = record Year: WORD; Month: WORD; DayOfWeek: WORD; Day: WORD; Hour: WORD; Minute: WORD; Second: WORD; Milliseconds: WORD; end; TIMEZONEINFORMATION = record Bias: Longint; StandardName: array[0..31] of WORD; StandardDate: SYSTEMTIME; StandardBias: Longint; DaylightName: array[0..31] of WORD; DaylightDate: SYSTEMTIME; DaylightBias: Longint; end; var fBackupDir: String; fPageBackupSize: TWizardPage; fLabelBackupSize: TLabel; procedure InitializeWizard; begin fPageBackupSize := CreateCustomPage(wpInfoAfter, 'Backup Space Usage', ''); fLabelBackupSize := TLabel.Create(fPageBackupSize); fLabelBackupSize.Top := ScaleY(10); fLabelBackupSize.Left := ScaleX(10); fLabelBackupSize.Width := fPageBackupSize.SurfaceWidth - ScaleX(2 * 10); fLabelBackupSize.Height := ScaleY(23); fLabelBackupSize.Parent := fPageBackupSize.Surface; end; function GetFileAttributesEx ( FileName: string; InfoLevelId: DWORD; var FileInformation: WIN32_FILE_ATTRIBUTE_DATA ): Boolean; external 'GetFileAttributesExA@kernel32.dll stdcall'; function FileTimeToSystemTime( FileTime: FILETIME; var SystemTime: SYSTEMTIME ): Boolean; external 'FileTimeToSystemTime@kernel32.dll stdcall'; function GetTimeZoneInformation( var TzInfo: TIMEZONEINFORMATION ): Boolean; external 'GetTimeZoneInformation@kernel32.dll stdcall'; function SystemTimeToTzSpecificLocalTime( TzInfo: TIMEZONEINFORMATION; // ALE 20151016 we always send NULL so don't bother defining it System: SYSTEMTIME; var LocalTime: SYSTEMTIME ): Boolean; external 'SystemTimeToTzSpecificLocalTime@kernel32.dll stdcall'; function GetFileDateTimeMod(pFPN: String): String; var FileInformation: WIN32_FILE_ATTRIBUTE_DATA; SystemTime: SYSTEMTIME; LocalTime: SYSTEMTIME; TzInformation: TIMEZONEINFORMATION; begin GetFileAttributesEx( pFPN, GetFileExInfoStandard, FileInformation); FileTimeToSystemTime( FileInformation.LastWriteTime, SystemTime); GetTimeZoneInformation(TzInformation); SystemTimeToTzSpecificLocalTime( TzInformation, SystemTime, LocalTime); result := Format('%4.4d%2.2d%2.2d_%2.2d%2.2d%2.2d', [LocalTime.Year, LocalTime.Month, LocalTime.Day, LocalTime.Hour, LocalTime.Minute, LocalTime.Second]); //MsgBox(result, mbInformation, MB_OK); end; // ALE 20151016 add up the space used by backups and report to user // cannot be called before BackupVersionedFile or BackupFile since // they are responsible for setting fBackupDir function GetBackupSize(): Cardinal; var lBackupSize: Cardinal; FindRec: TFindRec; begin lBackupSize := 0; if (DirExists(fBackupDir) = False) then begin Log('GetBackupSize returning 0, no backup directory present'); end else begin if (FindFirst(fBackupDir + '*', FindRec)) then begin try repeat // ALE 20151016 skip directories if (FindRec.Attributes AND FILE_ATTRIBUTE_DIRECTORY = 0) then begin lBackupSize := lBackupSize + FindRec.SizeLow; end; until (NOT FindNext(FindRec)); finally FindClose(FindRec); end; end else begin Log('GetBackupSize returning 0, no files found'); end; end; result := lBackupSize; end; procedure BackupVersionedFile(); var lFPN: String; lFN: String; lBackupFPN: String; lVerNum: String; begin lFPN := ExpandConstant(CurrentFilename); lFN := ExtractFileName(lFPN); // ALE 20160216 switched to {app} fBackupDir := ExtractFilePath(ExtractFilePath(lFPN) + 'Backups\'); fBackupDir := ExtractFilePath(ExpandConstant('{app}') + '\..\Backups\HCMQTT\'); if (GetVersionNumbersString(lFPN, lVerNum) = True) then begin lBackupFPN := fBackupDir + ChangeFileExt(ExtractFileName(lFPN), '_' + lVerNum + '_' + GetFileDateTimeMod(lFPN) + ExtractFileExt(lFPN)); if (FileExists(lBackupFPN) = False) then begin Log('Backing up ' + lFPN + ' to ' + lBackupFPN); if (ForceDirectories(ExtractFilePath(lBackupFPN)) = True) then begin if (FileCopy(lFPN, lBackupFPN, False) = True) then begin Log('Successfully backed up ' + lFN); end else begin Log('Failed to back up ' + lFN); end; end else begin Log('Failed create back up directory ' + ExtractFilePath(lBackupFPN)); end; end else begin Log('Skipped backing up ' + lFPN + ' since it already exists in backup'); end; //MsgBox('About to backup ' + lFPN + ' to ' + lBackupFPN, mbInformation, MB_OK); end else begin Log('Failed to back up ' + lFN + ', could not extract version information'); //MsgBox('Backup of ' + lFPN + ' failed.', mbInformation, MB_OK); end; end; procedure BackupFile(); var lFPN: String; lFN: String; lBackupFPN: String; lVerNum: String; begin lFPN := ExpandConstant(CurrentFilename); lFN := ExtractFileName(lFPN); // ALE 20160216 switched to {app} fBackupDir := ExtractFilePath(ExtractFilePath(lFPN) + 'Backups\'); fBackupDir := ExtractFilePath(ExpandConstant('{app}') + '\..\Backups\HCMQTT\'); lBackupFPN := fBackupDir + ChangeFileExt(ExtractFileName(lFPN), '_' + GetFileDateTimeMod(lFPN) + ExtractFileExt(lFPN)); if (FileExists(lBackupFPN) = False) then begin Log('Backing up ' + lFPN + ' to ' + lBackupFPN); if (ForceDirectories(ExtractFilePath(lBackupFPN)) = True) then begin if (FileCopy(lFPN, lBackupFPN, False) = True) then begin Log('Successfully backed up ' + lFN); end else begin Log('Failed to back up ' + lFN); end; end else begin Log('Failed create back up directory ' + ExtractFilePath(lBackupFPN)); end; end else begin Log('Skipped backing up ' + lFPN + ' since it already exists in backup'); end; //MsgBox('About to backup ' + lFPN + ' to ' + lBackupFPN, mbInformation, MB_OK); end; // ALE 20151016 We don't want to show the backup space page if there // are no backups. Conversely we need to check for backups and this // is a good place to do that. function ShouldSkipPage(PageID: Integer): Boolean; var lBackupSize: Cardinal; begin { Skip pages that shouldn't be shown } if (PageID = fPageBackupSize.ID) then begin lBackupSize := GetBackupSize(); if (lBackupSize > 0) then begin fPageBackupSize.Description := 'Backups are stored at ' + fBackupDir + ' in case you want to reclaim space'; fLabelBackupSize.Font.Size := fLabelBackupSize.Font.Size + 2; fLabelBackupSize.Caption := 'Backups are using ' + Format('%.0n', [lBackupSize/(1000.0*1000.00)]) + ' MB of space'; Result := False; end else begin Result := True; end; end else begin result := False; end; end; [InnoIDE_Settings] LogFileOverwrite=false