mirror of
https://github.com/PaperCutSoftware/GhostTrap.git
synced 2025-12-11 17:37:35 -06:00
Merged in PO-1913-add-dot-NET-runtime-requirement-to-installer (pull request #4)
PO-1913 add dot NET runtime requirement to installer Approved-by: Paul Mendoza
This commit is contained in:
commit
b78e4cbddf
@ -1,6 +1,6 @@
|
|||||||
; Copyright (c) 2012-2024 PaperCut Software Pty Ltd
|
; Copyright (c) 2012-2024 PaperCut Software Pty Ltd
|
||||||
; Author: Chris Dance <chris.dance@papercut.com>
|
; Author: Chris Dance <chris.dance@papercut.com>
|
||||||
;
|
;
|
||||||
; License: GNU Affero GPL v3 - See project LICENSE file.
|
; License: GNU Affero GPL v3 - See project LICENSE file.
|
||||||
;
|
;
|
||||||
; Ghost Trap Inno Setup based installer script.
|
; Ghost Trap Inno Setup based installer script.
|
||||||
@ -86,19 +86,22 @@ Type: filesandordirs; Name: {app}\lib\cidfmap;
|
|||||||
[Code]
|
[Code]
|
||||||
|
|
||||||
const
|
const
|
||||||
; Expected minimum version is 14.38.33130.00, for Visual C++ 2015 redistributable packs
|
{ Expected minimum version is 14.38.33130.00, for Visual C++ 2015 redistributable packs
|
||||||
; Update the values here if our requirements change over time
|
Update the values here if our requirements change over time }
|
||||||
MinMajor = 14;
|
MinMajor = 14;
|
||||||
{ only applies if actual major version is 14, do not apply if actual major version is higher }
|
{ only applies if actual major version is 14, do not apply if actual major version is higher }
|
||||||
MinMinor = 38;
|
MinMinor = 38;
|
||||||
{ only applies if actual major is 14 and actual minor 38, do not apply if previous versions are higher }
|
{ only applies if actual major is 14 and actual minor 38, do not apply if previous versions are higher }
|
||||||
MinBld = 33130;
|
MinBld = 33130;
|
||||||
|
|
||||||
; Used to store value of whether we have acceptable Visual C++ Runtime components
|
{ Used to store value of whether we have acceptable Visual C++ Runtime components }
|
||||||
var
|
var
|
||||||
HasRequiredVCRuntimeVersion : Boolean;
|
HasRequiredVCRuntimeVersion : Boolean;
|
||||||
VCRuntimeMissingOptionsPage : TInputOptionWizardPage;
|
VCRuntimeMissingOptionsPage : TInputOptionWizardPage;
|
||||||
IsInstallationFinishedNormally : Boolean;
|
ReadMoreLink : TLabel;
|
||||||
|
|
||||||
|
procedure ExitProcess(ExitCode : Integer);
|
||||||
|
external 'ExitProcess@kernel32.dll stdcall';
|
||||||
|
|
||||||
function FontsDirWithForwardSlashes(Param: String): String;
|
function FontsDirWithForwardSlashes(Param: String): String;
|
||||||
begin
|
begin
|
||||||
@ -142,7 +145,7 @@ var
|
|||||||
sKey: String;
|
sKey: String;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
; for more info see https://learn.microsoft.com/en-us/cpp/windows/redistributing-visual-cpp-files?view=msvc-170#install-the-redistributable-packages
|
{ for more info see https://learn.microsoft.com/en-us/cpp/windows/redistributing-visual-cpp-files?view=msvc-170#install-the-redistributable-packages }
|
||||||
sKey := 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64';
|
sKey := 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64';
|
||||||
if RegQueryDWordValue(HKEY_LOCAL_MACHINE, sKey, 'Major', cMajor) then begin
|
if RegQueryDWordValue(HKEY_LOCAL_MACHINE, sKey, 'Major', cMajor) then begin
|
||||||
if RegQueryDWordValue(HKEY_LOCAL_MACHINE, sKey, 'Minor', cMinor) then begin
|
if RegQueryDWordValue(HKEY_LOCAL_MACHINE, sKey, 'Minor', cMinor) then begin
|
||||||
@ -175,43 +178,84 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure InitializeWizard();
|
procedure OpenBrowser(Url: string);
|
||||||
|
var
|
||||||
|
ErrorCode: Integer;
|
||||||
begin
|
begin
|
||||||
HasRequiredVCRuntimeVersion := IsRequiredVCRuntimeVersionInstalled();
|
ShellExec('open', Url, '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
|
||||||
; If the OS is missing required dependencies, the installation process will not go the full length and will be aborted early
|
end;
|
||||||
if not HasRequiredVCRuntimeVersion then begin
|
|
||||||
IsInstallationFinishedNormally := False;
|
|
||||||
VCRuntimeMissingOptionsPage := CreateInputOptionPage(wpWelcome,
|
|
||||||
'Visual C++ Runtime Required',
|
|
||||||
'You are seeing this page because required dependencies for GhostTrap are missing on your operating system.',
|
|
||||||
'GhostTrap of version 1.4.10.02 and above requires reasonably up-to-date Visual C++ Runtimes to function properly. You must install required Microsoft Redistributables before installing GhostTrap.' + #13#10 + #13#10 + 'Either option will terminate the current installation process.' + #13#10 + 'Read more about this: https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170#visual-studio-2015-2017-2019-and-2022',
|
|
||||||
False, False);
|
|
||||||
|
|
||||||
VCRuntimeMissingOptionsPage.Add('Install the dependencies from Microsoft now. (Recommended)');
|
procedure ReadMoreLinkClick(Sender : TObject);
|
||||||
VCRuntimeMissingOptionsPage.Add('I will find the required dependencies myself later.');
|
begin
|
||||||
end;
|
OpenBrowser('https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170#visual-studio-2015-2017-2019-and-2022');
|
||||||
; If the OS has the required dependencies, completion of the installation is treated as normal
|
end;
|
||||||
else
|
|
||||||
begin
|
procedure CreateLink();
|
||||||
IsInstallationFinishedNormally := True;
|
begin
|
||||||
|
ReadMoreLink := TLabel.Create(WizardForm);
|
||||||
|
ReadMoreLink.Parent := WizardForm;
|
||||||
|
ReadMoreLink.Left := 8;
|
||||||
|
ReadMoreLink.Top := WizardForm.ClientHeight - ReadMoreLink.ClientHeight - 15;
|
||||||
|
ReadMoreLink.Cursor := crHand;
|
||||||
|
ReadMoreLink.Font.Color := clBlue;
|
||||||
|
ReadMoreLink.Caption := 'Read more about Visual C++ dependencies';
|
||||||
|
ReadMoreLink.OnCLick := @ReadMoreLinkClick;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ Only display Read More link on added custom page, also set up custom page }
|
||||||
|
procedure CurPageChanged(CurPageID: Integer);
|
||||||
|
begin
|
||||||
|
ReadMoreLink.Visible := CurPageID = VCRuntimeMissingOptionsPage.ID;
|
||||||
|
if CurPageID = VCRuntimeMissingOptionsPage.ID then begin
|
||||||
|
WizardForm.BackButton.Visible := False;
|
||||||
|
WizardForm.CancelButton.Visible := False;
|
||||||
|
WizardForm.NextButton.Caption := 'Finish';
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure CurStepChanged(CurStep : TSetupStep);
|
function NextButtonClick(CurPageID: Integer): Boolean;
|
||||||
var
|
var
|
||||||
ErrorCode : Integer;
|
ErrorCode : Integer;
|
||||||
|
InstallNow : Boolean;
|
||||||
begin
|
begin
|
||||||
if (curStep = ssPostInstall) and not ((WizardForm.Canceled) or (IsInstallationFinishedNormally)) then begin
|
{ Handle the "Finish" button being clicked on the custom page }
|
||||||
case VCRuntimeMissingOptionsPage.Values[0] of
|
if CurPageID = VCRuntimeMissingOptionsPage.ID then begin
|
||||||
0: begin
|
InstallNow := VCRuntimeMissingOptionsPage.Values[0];
|
||||||
{ install dependencies now, using Microsoft's perma-link }
|
if InstallNow then begin
|
||||||
ShellExec('', 'https://aka.ms/vs/17/release/vc_redist.x64.exe', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
|
if MsgBox('Would you like to install required dependencies now?', mbInformation, MB_YESNO or MB_DEFBUTTON1) = IDYES then begin
|
||||||
Abort;
|
ShellExec('', 'https://aka.ms/vs/17/release/vc_redist.x64.exe', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
|
||||||
end;
|
ExitProcess(9); { Custom exit code }
|
||||||
1: begin
|
end;
|
||||||
{ do it later themselves }
|
end else begin
|
||||||
MsgBox('Please install required VC++ dependencies first and try again.', mbInformation, MB_OK);
|
MsgBox('Please install required VC++ dependencies first and try again.', mbInformation, MB_OK);
|
||||||
Abort;
|
ExitProcess(9); { Custom exit code }
|
||||||
end;
|
end;
|
||||||
|
Result := False;
|
||||||
|
end else begin
|
||||||
|
Result := True;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ While the custom page is always created, it should be skipped if dependencies are already installed }
|
||||||
|
function ShouldSkipPage(PageID: Integer): Boolean;
|
||||||
|
begin
|
||||||
|
{ For potentially different custom page in the future, compare page ID one at a time }
|
||||||
|
Result := (PageID = VCRuntimeMissingOptionsPage.ID) and HasRequiredVCRuntimeVersion;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure InitializeWizard();
|
||||||
|
begin
|
||||||
|
{ If the OS is missing required dependencies, the installation process will not go the full length and will be exited early }
|
||||||
|
HasRequiredVCRuntimeVersion := IsRequiredVCRuntimeVersionInstalled();
|
||||||
|
{ Create the custom page to handle the scenario where dependencies don't exist }
|
||||||
|
VCRuntimeMissingOptionsPage := CreateInputOptionPage(wpLicense,
|
||||||
|
'Visual C++ Runtime Required',
|
||||||
|
'You are seeing this page because required dependencies for GhostTrap are missing on your operating system.',
|
||||||
|
'GhostTrap of version 1.4.10.02 and above requires reasonably up-to-date Visual C++ Runtimes to function properly. You must install required Microsoft Redistributables before installing GhostTrap.' + #13#10 + #13#10 + 'Either option will terminate the current installation process.',
|
||||||
|
True, False);
|
||||||
|
|
||||||
|
VCRuntimeMissingOptionsPage.Add('&Install the dependencies from Microsoft now. (Recommended)');
|
||||||
|
VCRuntimeMissingOptionsPage.Add('I will find the required dependencies myself later.');
|
||||||
|
VCRuntimeMissingOptionsPage.Values[0] := True;
|
||||||
|
CreateLink();
|
||||||
|
end;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user