11#define ReleaseFilesPath " ..\ReleaseFiles\"
22#define AppName " CalibreImport"
3+ #define MainDll " CalibreImport.dll"
34
45[Setup]
56AppName = {#AppName}
67AppVersion = 1.0
78DefaultDirName = {pf} \{#AppName}
89DefaultGroupName = {#AppName}
9- UninstallDisplayIcon = {app} \{#AppName}.dll
10+ UninstallDisplayIcon = {app} \{#MainDll}
1011OutputDir = {#ReleaseFilesPath}
1112OutputBaseFilename = CalibreImportSetup
1213Compression = lzma
1314SolidCompression = yes
1415PrivilegesRequired = 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
2023Source : " {#ReleaseFilesPath}*.config" ; DestDir : " {userappdata}\{#AppName}" ; Flags : ignoreversion
2124
2225[Code]
@@ -34,40 +37,57 @@ begin
3437 end ;
3538end ;
3639
37- procedure RegisterDLLs ;
40+ function RegisterMainDLL : Boolean ;
3841var
39- FindRec: TFindRec;
4042 RegAsmPath: String;
4143 ResultCode: Integer;
4244begin
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 ;
6478end ;
6579
6680procedure InitializeWizard ;
6781begin
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 ;
7393end ;
@@ -76,6 +96,13 @@ procedure CurStepChanged(CurStep: TSetupStep);
7696begin
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 ;
81108end ;
0 commit comments