From 516f4816b99a845cf284178c6b4d97591dcc989c Mon Sep 17 00:00:00 2001 From: lx-s Date: Tue, 2 Aug 2022 14:31:17 +0200 Subject: [PATCH] Added InnoSetup --- Dist/InnoSetup/winmute-setup.iss | 262 +++++++++++++++++++++++++++++++ LICENSE | 2 +- Setup/wmsetup.iss | 58 ------- 3 files changed, 263 insertions(+), 59 deletions(-) create mode 100644 Dist/InnoSetup/winmute-setup.iss delete mode 100644 Setup/wmsetup.iss diff --git a/Dist/InnoSetup/winmute-setup.iss b/Dist/InnoSetup/winmute-setup.iss new file mode 100644 index 0000000..99192c4 --- /dev/null +++ b/Dist/InnoSetup/winmute-setup.iss @@ -0,0 +1,262 @@ +[Code] +// types and variables +type + TDependency_Entry = record + Filename: String; + Parameters: String; + Title: String; + URL: String; + Checksum: String; + ForceSuccess: Boolean; + RestartAfter: Boolean; + end; +var + Dependency_Memo: String; + Dependency_List: array of TDependency_Entry; + Dependency_NeedRestart, Dependency_ForceX86: Boolean; + Dependency_DownloadPage: TDownloadWizardPage; +procedure Dependency_Add(const Filename, Parameters, Title, URL, Checksum: String; const ForceSuccess, RestartAfter: Boolean); +var + Dependency: TDependency_Entry; + DependencyCount: Integer; +begin + Dependency_Memo := Dependency_Memo + #13#10 + '%1' + Title; + Dependency.Filename := Filename; + Dependency.Parameters := Parameters; + Dependency.Title := Title; + if FileExists(ExpandConstant('{tmp}{\}') + Filename) then begin + Dependency.URL := ''; + end else begin + Dependency.URL := URL; + end; + Dependency.Checksum := Checksum; + Dependency.ForceSuccess := ForceSuccess; + Dependency.RestartAfter := RestartAfter; + DependencyCount := GetArrayLength(Dependency_List); + SetArrayLength(Dependency_List, DependencyCount + 1); + Dependency_List[DependencyCount] := Dependency; +end; + +procedure Dependency_Internal1; +begin + Dependency_DownloadPage := CreateDownloadPage(SetupMessage(msgWizardPreparing), SetupMessage(msgPreparingDesc), nil); +end; + +function Dependency_Internal2(var NeedsRestart: Boolean): String; +var + DependencyCount, DependencyIndex, ResultCode: Integer; + Retry: Boolean; + TempValue: String; +begin + DependencyCount := GetArrayLength(Dependency_List); + if DependencyCount > 0 then begin + Dependency_DownloadPage.Show; + for DependencyIndex := 0 to DependencyCount - 1 do begin + if Dependency_List[DependencyIndex].URL <> '' then begin + Dependency_DownloadPage.Clear; + Dependency_DownloadPage.Add(Dependency_List[DependencyIndex].URL, Dependency_List[DependencyIndex].Filename, Dependency_List[DependencyIndex].Checksum); + Retry := True; + while Retry do begin + Retry := False; + try + Dependency_DownloadPage.Download; + except + if Dependency_DownloadPage.AbortedByUser then begin + Result := Dependency_List[DependencyIndex].Title; + DependencyIndex := DependencyCount; + end else begin + case SuppressibleMsgBox(AddPeriod(GetExceptionMessage), mbError, MB_ABORTRETRYIGNORE, IDIGNORE) of + IDABORT: begin + Result := Dependency_List[DependencyIndex].Title; + DependencyIndex := DependencyCount; + end; + IDRETRY: begin + Retry := True; + end; + end; + end; + end; + end; + end; + end; + if Result = '' then begin + for DependencyIndex := 0 to DependencyCount - 1 do begin + Dependency_DownloadPage.SetText(Dependency_List[DependencyIndex].Title, ''); + Dependency_DownloadPage.SetProgress(DependencyIndex + 1, DependencyCount + 1); + while True do begin + ResultCode := 0; + if ShellExec('', ExpandConstant('{tmp}{\}') + Dependency_List[DependencyIndex].Filename, Dependency_List[DependencyIndex].Parameters, '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode) then begin + if Dependency_List[DependencyIndex].RestartAfter then begin + if DependencyIndex = DependencyCount - 1 then begin + Dependency_NeedRestart := True; + end else begin + NeedsRestart := True; + Result := Dependency_List[DependencyIndex].Title; + end; + break; + end else if (ResultCode = 0) or Dependency_List[DependencyIndex].ForceSuccess then begin // ERROR_SUCCESS (0) + break; + end else if ResultCode = 1641 then begin // ERROR_SUCCESS_REBOOT_INITIATED (1641) + NeedsRestart := True; + Result := Dependency_List[DependencyIndex].Title; + break; + end else if ResultCode = 3010 then begin // ERROR_SUCCESS_REBOOT_REQUIRED (3010) + Dependency_NeedRestart := True; + break; + end; + end; + case SuppressibleMsgBox(FmtMessage(SetupMessage(msgErrorFunctionFailed), [Dependency_List[DependencyIndex].Title, IntToStr(ResultCode)]), mbError, MB_ABORTRETRYIGNORE, IDIGNORE) of + IDABORT: begin + Result := Dependency_List[DependencyIndex].Title; + break; + end; + IDIGNORE: begin + break; + end; + end; + end; + if Result <> '' then begin + break; + end; + end; + if NeedsRestart then begin + TempValue := '"' + ExpandConstant('{srcexe}') + '" /restart=1 /LANG="' + ExpandConstant('{language}') + '" /DIR="' + WizardDirValue + '" /GROUP="' + WizardGroupValue + '" /TYPE="' + WizardSetupType(False) + '" /COMPONENTS="' + WizardSelectedComponents(False) + '" /TASKS="' + WizardSelectedTasks(False) + '"'; + if WizardNoIcons then begin + TempValue := TempValue + ' /NOICONS'; + end; + RegWriteStringValue(HKA, 'SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce', '{#SetupSetting("AppName")}', TempValue); + end; + end; + Dependency_DownloadPage.Hide; + end; +end; + +function Dependency_Internal3(const Space, NewLine, MemoUserInfoInfo, MemoDirInfo, MemoTypeInfo, MemoComponentsInfo, MemoGroupInfo, MemoTasksInfo: String): String; +begin + Result := ''; + if MemoUserInfoInfo <> '' then begin + Result := Result + MemoUserInfoInfo + Newline + NewLine; + end; + if MemoDirInfo <> '' then begin + Result := Result + MemoDirInfo + Newline + NewLine; + end; + if MemoTypeInfo <> '' then begin + Result := Result + MemoTypeInfo + Newline + NewLine; + end; + if MemoComponentsInfo <> '' then begin + Result := Result + MemoComponentsInfo + Newline + NewLine; + end; + if MemoGroupInfo <> '' then begin + Result := Result + MemoGroupInfo + Newline + NewLine; + end; + if MemoTasksInfo <> '' then begin + Result := Result + MemoTasksInfo; + end; + if Dependency_Memo <> '' then begin + if MemoTasksInfo = '' then begin + Result := Result + SetupMessage(msgReadyMemoTasks); + end; + Result := Result + FmtMessage(Dependency_Memo, [Space]); + end; +end; + +function Dependency_Internal4: Boolean; +begin + Result := Dependency_NeedRestart; +end; +function Dependency_IsX64: Boolean; +begin + Result := not Dependency_ForceX86 and Is64BitInstallMode; +end; +function Dependency_String(const x86, x64: String): String; +begin + if Dependency_IsX64 then begin + Result := x64; + end else begin + Result := x86; + end; +end; +function Dependency_ArchSuffix: String; +begin + Result := Dependency_String('', '_x64'); +end; +function Dependency_ArchTitle: String; +begin + Result := Dependency_String(' (x86)', ' (x64)'); +end; +procedure Dependency_AddVC2015To2022; +begin + // https://docs.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist + if not IsMsiProductInstalled(Dependency_String('{65E5BD06-6392-3027-8C26-853107D3CF1A}', '{36F68A90-239C-34DF-B58C-64B30153CE35}'), PackVersionComponents(14, 30, 30704, 0)) then begin + Dependency_Add('vcredist2022' + Dependency_ArchSuffix + '.exe', + '/passive /norestart', + 'Visual C++ 2015-2022 Redistributable' + Dependency_ArchTitle, + Dependency_String('https://aka.ms/vs/17/release/vc_redist.x86.exe', 'https://aka.ms/vs/17/release/vc_redist.x64.exe'), + '', False, False); + end; +end; + +#define MyAppName "WinMute" +#define MyAppVersion "2.1.0.0" +#define MyAppPublisher "LX-Systems" +#define MyAppURL "https://www.lx-s.de/winmute" +#define MyAppExeName "WinMute.exe" + +[Setup] +AppId={{D2E8F9EF-11E7-418B-B9B7-A35A69A30490} +AppName={#MyAppName} +AppVersion={#MyAppVersion} +;AppVerName={#MyAppName} {#MyAppVersion} +AppPublisher={#MyAppPublisher} +AppPublisherURL={#MyAppURL} +AppSupportURL={#MyAppURL} +AppUpdatesURL={#MyAppURL} +DefaultDirName={autopf}\{#MyAppName} +DisableProgramGroupPage=yes +LicenseFile=..\bin\license.txt +PrivilegesRequiredOverridesAllowed=dialog +OutputDir=..\bin\ +OutputBaseFilename=winmute-setup +SetupIconFile=..\..\WinMute\icons\app.ico +ArchitecturesInstallIn64BitMode=x64 +Compression=lzma +SolidCompression=yes +WizardStyle=modern + +[Languages] +Name: "en"; MessagesFile: "compiler:Default.isl" +Name: "de"; MessagesFile: "compiler:Languages\German.isl" + +[Tasks] +Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked + +[Files] +Source: "..\bin\{#MyAppExeName}"; DestDir: "{app}"; Check: Dependency_IsX64; Flags: ignoreversion +Source: "..\bin\changelog.txt"; DestDir: "{app}"; Flags: ignoreversion +Source: "..\bin\license.txt"; DestDir: "{app}"; Flags: ignoreversion +Source: "..\bin\liesmich.html"; DestDir: "{app}"; Flags: ignoreversion +Source: "..\bin\readme.html"; DestDir: "{app}"; Flags: ignoreversion +Source: "..\bin\ScreensaverNotify.dll"; DestDir: "{app}"; Check: Dependency_IsX64; Flags: ignoreversion +Source: "..\bin\ScreensaverNotify32.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "..\bin\ScreensaverProxy32.exe"; DestDir: "{app}"; Flags: ignoreversion + +[Icons] +Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" +Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon + +[Registry] +Root: HKCU; Subkey: "Software\lx-systems"; Flags: uninsdeletekeyifempty +Root: HKCU; Subkey: "Software\lx-systems\WinMute"; Flags: uninsdeletekey +Root: HKCU; Subkey: "Software\lx-systems\WinMute"; ValueType: string; ValueName: "InstallPath"; ValueData: "{app}" +Root: HKCU; Subkey: "Software\lx-systems\WinMute\BluetoothDevices"; Flags: uninsdeletekey +Root: HKCU; Subkey: "Software\lx-systems\WinMute\WifiNetworks"; Flags: uninsdeletekey + +[Run] +Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent + +[Code] +function InitializeSetup: Boolean; +begin + Dependency_AddVC2015To2022; + Result := True; +end; diff --git a/LICENSE b/LICENSE index 6434c53..940fa6e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (C) 2016, Alexander Steinhoefer +Copyright (C) 2022, Alexander Steinhoefer All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/Setup/wmsetup.iss b/Setup/wmsetup.iss deleted file mode 100644 index 4967476..0000000 --- a/Setup/wmsetup.iss +++ /dev/null @@ -1,58 +0,0 @@ -; Script generated by the Inno Setup Script Wizard. -; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! - -#define MyAppName "WinMute" -#define MyAppVersion "2.0.0.0" -#define MyAppPublisher "LX-Systems" -#define MyAppURL "https://www.lx-s.de/winmute" -#define MyAppExeName "WinMute.exe" - -[Setup] -; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications. -; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) -AppId={{D2E8F9EF-11E7-418B-B9B7-A35A69A30490} -AppName={#MyAppName} -AppVersion={#MyAppVersion} -;AppVerName={#MyAppName} {#MyAppVersion} -AppPublisher={#MyAppPublisher} -AppPublisherURL={#MyAppURL} -AppSupportURL={#MyAppURL} -AppUpdatesURL={#MyAppURL} -DefaultDirName={autopf}\{#MyAppName} -DisableProgramGroupPage=yes -LicenseFile=E:\Development\Code\WinMute\Dist\bin\license.txt -InfoAfterFile=E:\Development\Code\WinMute\Dist\bin\readme.html -; Uncomment the following line to run in non administrative install mode (install for current user only.) -;PrivilegesRequired=lowest -PrivilegesRequiredOverridesAllowed=dialog -OutputDir=E:\Development\Code\WinMute\Build\Setup -OutputBaseFilename=wm-setup -SetupIconFile=E:\Development\Code\WinMute\WinMute\icons\app.ico -Compression=lzma -SolidCompression=yes -WizardStyle=modern - -[Languages] -Name: "english"; MessagesFile: "compiler:Default.isl" - -[Tasks] -Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked - -[Files] -Source: "E:\Development\Code\WinMute\Dist\bin\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion -Source: "E:\Development\Code\WinMute\Dist\bin\changelog.txt"; DestDir: "{app}"; Flags: ignoreversion -Source: "E:\Development\Code\WinMute\Dist\bin\license.txt"; DestDir: "{app}"; Flags: ignoreversion -Source: "E:\Development\Code\WinMute\Dist\bin\liesmich.html"; DestDir: "{app}"; Flags: ignoreversion -Source: "E:\Development\Code\WinMute\Dist\bin\readme.html"; DestDir: "{app}"; Flags: ignoreversion -Source: "E:\Development\Code\WinMute\Dist\bin\ScreensaverNotify.dll"; DestDir: "{app}"; Flags: ignoreversion -Source: "E:\Development\Code\WinMute\Dist\bin\ScreensaverNotify32.dll"; DestDir: "{app}"; Flags: ignoreversion -Source: "E:\Development\Code\WinMute\Dist\bin\ScreensaverProxy32.exe"; DestDir: "{app}"; Flags: ignoreversion -; NOTE: Don't use "Flags: ignoreversion" on any shared system files - -[Icons] -Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" -Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon - -[Run] -Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent - -- 2.43.0