rom validation in setup. Will warn about headered files for now. Someone who wants to deal with pascal is welcome to add a check for it.

This commit is contained in:
Fabian Dill 2020-04-07 05:41:44 +02:00
parent e209f00881
commit b427f03e5f
1 changed files with 116 additions and 112 deletions

View File

@ -1,112 +1,116 @@
#define sourcepath "build\exe.win-amd64-3.8\" #define sourcepath "build\exe.win-amd64-3.8\"
#define MyAppName "BerserkerMultiWorld" #define MyAppName "BerserkerMultiWorld"
#define MyAppExeName "BerserkerMultiClient.exe" #define MyAppExeName "BerserkerMultiClient.exe"
#define MyAppIcon "icon.ico" #define MyAppIcon "icon.ico"
[Setup] [Setup]
; NOTE: The value of AppId uniquely identifies this application. ; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications. ; Do not use the same AppId value in installers for other applications.
AppId={{6D826EE0-49BE-4B36-BACE-09C6971CD85C}} AppId={{6D826EE0-49BE-4B36-BACE-09C6971CD85C}}
AppName={#MyAppName} AppName={#MyAppName}
AppVerName={#MyAppName} AppVerName={#MyAppName}
DefaultDirName={commonappdata}\{#MyAppName} DefaultDirName={commonappdata}\{#MyAppName}
DisableProgramGroupPage=yes DisableProgramGroupPage=yes
OutputDir=setups OutputDir=setups
OutputBaseFilename=Setup {#MyAppName} OutputBaseFilename=Setup {#MyAppName}
Compression=lzma2 Compression=lzma2
SolidCompression=yes SolidCompression=yes
LZMANumBlockThreads=8 LZMANumBlockThreads=8
ArchitecturesInstallIn64BitMode=x64 ArchitecturesInstallIn64BitMode=x64
ChangesAssociations=yes ChangesAssociations=yes
ArchitecturesAllowed=x64 ArchitecturesAllowed=x64
AllowNoIcons=yes AllowNoIcons=yes
SetupIconFile={#MyAppIcon} SetupIconFile={#MyAppIcon}
UninstallDisplayIcon={app}\{#MyAppExeName} UninstallDisplayIcon={app}\{#MyAppExeName}
LicenseFile= LICENSE LicenseFile= LICENSE
WizardStyle= modern WizardStyle= modern
SetupLogging=yes SetupLogging=yes
[Languages] [Languages]
Name: "english"; MessagesFile: "compiler:Default.isl" Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks] [Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}";
[Dirs] [Dirs]
NAME: "{app}"; Flags: setntfscompression; Permissions: everyone-modify users-modify authusers-modify; NAME: "{app}"; Flags: setntfscompression; Permissions: everyone-modify users-modify authusers-modify;
[Files] [Files]
Source: "{code:GetROMPath}"; DestDir: "{app}"; DestName: "Zelda no Densetsu - Kamigami no Triforce (Japan).sfc"; Flags: external Source: "{code:GetROMPath}"; DestDir: "{app}"; DestName: "Zelda no Densetsu - Kamigami no Triforce (Japan).sfc"; Flags: external
Source: "{#sourcepath}*"; Excludes: "*.key, *.log, *.hpkey"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "{#sourcepath}*"; Excludes: "*.key, *.log, *.hpkey"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "vc_redist.x64.exe"; DestDir: {tmp}; Flags: deleteafterinstall Source: "vc_redist.x64.exe"; DestDir: {tmp}; Flags: deleteafterinstall
; NOTE: Don't use "Flags: ignoreversion" on any shared system files ; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons] [Icons]
Name: "{group}\{#MyAppName} Folder"; Filename: "{app}"; Name: "{group}\{#MyAppName} Folder"; Filename: "{app}";
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}";
Name: "{commondesktop}\{#MyAppName} Folder"; Filename: "{app}"; Tasks: desktopicon Name: "{commondesktop}\{#MyAppName} Folder"; Filename: "{app}"; Tasks: desktopicon
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
[Run] [Run]
Filename: "{tmp}\vc_redist.x64.exe"; Parameters: "/passive /norestart"; Check: IsVCRedist64BitNeeded; StatusMsg: "Installing VC++ redistributable..." Filename: "{tmp}\vc_redist.x64.exe"; Parameters: "/passive /norestart"; Check: IsVCRedist64BitNeeded; StatusMsg: "Installing VC++ redistributable..."
; Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent ; Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
[UninstallDelete] [UninstallDelete]
Type: dirifempty; Name: "{app}" Type: dirifempty; Name: "{app}"
[Registry] [Registry]
Root: HKCR; Subkey: ".bmbp"; ValueData: "{#MyAppName}patch"; Flags: uninsdeletevalue; ValueType: string; ValueName: "" Root: HKCR; Subkey: ".bmbp"; ValueData: "{#MyAppName}patch"; Flags: uninsdeletevalue; ValueType: string; ValueName: ""
Root: HKCR; Subkey: "{#MyAppName}patch"; ValueData: "{#MyAppName} Patch"; Flags: uninsdeletekey; ValueType: string; ValueName: "" Root: HKCR; Subkey: "{#MyAppName}patch"; ValueData: "{#MyAppName} Patch"; Flags: uninsdeletekey; ValueType: string; ValueName: ""
Root: HKCR; Subkey: "{#MyAppName}patch\DefaultIcon"; ValueData: "{app}\{#MyAppExeName},0"; ValueType: string; ValueName: "" Root: HKCR; Subkey: "{#MyAppName}patch\DefaultIcon"; ValueData: "{app}\{#MyAppExeName},0"; ValueType: string; ValueName: ""
Root: HKCR; Subkey: "{#MyAppName}patch\shell\open\command"; ValueData: """{app}\{#MyAppExeName}"" ""%1"""; ValueType: string; ValueName: "" Root: HKCR; Subkey: "{#MyAppName}patch\shell\open\command"; ValueData: """{app}\{#MyAppExeName}"" ""%1"""; ValueType: string; ValueName: ""
[Code] [Code]
// See: https://stackoverflow.com/a/51614652/2287576 // See: https://stackoverflow.com/a/51614652/2287576
function IsVCRedist64BitNeeded(): boolean; function IsVCRedist64BitNeeded(): boolean;
var var
strVersion: string; strVersion: string;
begin begin
if (RegQueryStringValue(HKEY_LOCAL_MACHINE, if (RegQueryStringValue(HKEY_LOCAL_MACHINE,
'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64', 'Version', strVersion)) then 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64', 'Version', strVersion)) then
begin begin
// Is the installed version at least 14.24 ? // Is the installed version at least 14.24 ?
Log('VC Redist x64 Version : found ' + strVersion); Log('VC Redist x64 Version : found ' + strVersion);
Result := (CompareStr(strVersion, 'v14.24.28127.4') < 0); Result := (CompareStr(strVersion, 'v14.24.28127.4') < 0);
end end
else else
begin begin
// Not even an old version installed // Not even an old version installed
Log('VC Redist x64 is not already installed'); Log('VC Redist x64 is not already installed');
Result := True; Result := True;
end; end;
end; end;
var var ROMFilePage: TInputFileWizardPage;
ROMFilePage: TInputFileWizardPage; var R : longint;
procedure InitializeWizard(); procedure InitializeWizard();
begin begin
ROMFilePage := ROMFilePage :=
CreateInputFilePage( CreateInputFilePage(
wpLicense, wpLicense,
'Select ROM File', 'Select ROM File',
'Where is your Zelda no Densetsu - Kamigami no Triforce (Japan).sfc located?', 'Where is your Zelda no Densetsu - Kamigami no Triforce (Japan).sfc located?',
'Select the file, then click Next.'); 'Select the file, then click Next.');
ROMFilePage.Add( ROMFilePage.Add(
'Location of ROM file:', 'Location of ROM file:',
'SNES ROM files|*.sfc|All files|*.*', 'SNES ROM files|*.sfc|All files|*.*',
'.sfc'); '.sfc');
end; end;
function GetROMPath(Param: string): string; function GetROMPath(Param: string): string;
begin begin
if Assigned(RomFilePage) then if Assigned(RomFilePage) then begin
Result := ROMFilePage.Values[0] R := CompareStr(GetMD5OfFile(ROMFilePage.Values[0]), '03a63945398191337e896e5771f77173')
else if R <> 0 then
Result := ''; MsgBox('ROM validation failed. Very likely wrong file.', mbInformation, MB_OK);
end; Result := ROMFilePage.Values[0]
end
else
Result := '';
end;