Skip to content

Commit d77ff0e

Browse files
Improved the Setup executable
1 parent 1d99c1d commit d77ff0e

File tree

2 files changed

+51
-24
lines changed

2 files changed

+51
-24
lines changed
Lines changed: 51 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
#define ReleaseFilesPath "..\ReleaseFiles\"
22
#define AppName "CalibreImport"
3+
#define MainDll "CalibreImport.dll"
34

45
[Setup]
56
AppName={#AppName}
67
AppVersion=1.0
78
DefaultDirName={pf}\{#AppName}
89
DefaultGroupName={#AppName}
9-
UninstallDisplayIcon={app}\{#AppName}.dll
10+
UninstallDisplayIcon={app}\{#MainDll}
1011
OutputDir={#ReleaseFilesPath}
1112
OutputBaseFilename=CalibreImportSetup
1213
Compression=lzma
1314
SolidCompression=yes
1415
PrivilegesRequired=admin
16+
ArchitecturesAllowed=x64
17+
ArchitecturesInstallIn64BitMode=x64
1518

1619
[Files]
17-
; Install all DLLs to application directory
18-
Source: "{#ReleaseFilesPath}*.dll"; DestDir: "{app}"; Flags: ignoreversion
19-
; Install config file to AppData
20+
; Install all files (x64)
21+
Source: "{#ReleaseFilesPath}*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Check: Is64BitInstallMode
22+
; Config file goes to AppData
2023
Source: "{#ReleaseFilesPath}*.config"; DestDir: "{userappdata}\{#AppName}"; Flags: ignoreversion
2124

2225
[Code]
@@ -34,40 +37,57 @@ begin
3437
end;
3538
end;
3639
37-
procedure RegisterDLLs;
40+
function RegisterMainDLL: Boolean;
3841
var
39-
FindRec: TFindRec;
4042
RegAsmPath: String;
4143
ResultCode: Integer;
4244
begin
43-
RegAsmPath := ExpandConstant('{win}\Microsoft.NET\Framework\v4.0.30319\regasm.exe');
45+
Result := False;
46+
47+
// Use 64-bit regasm explicitly
48+
RegAsmPath := ExpandConstant('{win}\Microsoft.NET\Framework64\v4.0.30319\regasm.exe');
49+
4450
if not FileExists(RegAsmPath) then
45-
RegAsmPath := ExpandConstant('{win}\Microsoft.NET\Framework64\v4.0.30319\regasm.exe');
51+
begin
52+
MsgBox('64-bit .NET Framework 4.8 not found. Please install it first.', mbError, MB_OK);
53+
Exit;
54+
end;
4655
47-
if FindFirst(ExpandConstant('{app}\*.dll'), FindRec) then
56+
Log('Attempting to register 64-bit DLL with: ' + RegAsmPath);
57+
58+
if Exec(RegAsmPath, ExpandConstant('"{app}\{#MainDll}" /codebase'), '',
59+
SW_HIDE, ewWaitUntilTerminated, ResultCode) then
4860
begin
49-
try
50-
repeat
51-
if (FindRec.Name <> '.') and (FindRec.Name <> '..') then
52-
begin
53-
if not Exec(RegAsmPath, ExpandConstant('"{app}\' + FindRec.Name + '" /codebase'), '',
54-
SW_HIDE, ewWaitUntilTerminated, ResultCode) then
55-
MsgBox('Failed to register ' + FindRec.Name + ': ' + SysErrorMessage(ResultCode), mbError, MB_OK)
56-
else if ResultCode <> 0 then
57-
MsgBox('Registration failed for ' + FindRec.Name + ' with code: ' + IntToStr(ResultCode), mbError, MB_OK);
58-
end;
59-
until not FindNext(FindRec);
60-
finally
61-
FindClose(FindRec);
61+
if ResultCode = 0 then
62+
begin
63+
Result := True;
64+
Log('64-bit DLL registration succeeded');
65+
end
66+
else
67+
begin
68+
Log('Registration failed with code: ' + IntToStr(ResultCode));
69+
MsgBox('Registration failed (Code ' + IntToStr(ResultCode) + '). ' +
70+
'Make sure this is a 64-bit .NET assembly and all dependencies are installed.',
71+
mbError, MB_OK);
6272
end;
73+
end
74+
else
75+
begin
76+
Log('Failed to execute regasm: ' + SysErrorMessage(ResultCode));
6377
end;
6478
end;
6579
6680
procedure InitializeWizard;
6781
begin
82+
if not Is64BitInstallMode then
83+
begin
84+
MsgBox('This application requires a 64-bit Windows system.', mbError, MB_OK);
85+
Abort;
86+
end;
87+
6888
if not IsDotNet48Installed then
6989
begin
70-
MsgBox('This application requires .NET Framework 4.8. Please install it and then run this setup again.', mbError, MB_OK);
90+
MsgBox('This application requires 64-bit .NET Framework 4.8. Please install it first.', mbError, MB_OK);
7191
Abort;
7292
end;
7393
end;
@@ -76,6 +96,13 @@ procedure CurStepChanged(CurStep: TSetupStep);
7696
begin
7797
if CurStep = ssPostInstall then
7898
begin
79-
RegisterDLLs;
99+
if not RegisterMainDLL then
100+
begin
101+
MsgBox('For manual registration, run as Administrator:' + #13#10#13#10 +
102+
'"%windir%\Microsoft.NET\Framework64\v4.0.30319\regasm.exe" "' +
103+
ExpandConstant('{app}\{#MainDll}') + '" /codebase' + #13#10#13#10 +
104+
'Check the log file for details: ' + ExpandConstant('{log}'),
105+
mbError, MB_OK);
106+
end;
80107
end;
81108
end;
1.89 KB
Binary file not shown.

0 commit comments

Comments
 (0)