@@ -47,8 +47,10 @@ Source: "{#BuildDir}\NativeBinaries\x86\*"; DestDir: "{app}"; Flags: ignoreversi
47
47
Source : " {#BuildDir}\{#AddinDLL}" ; DestDir : " {app} " ; Flags : ignoreversion ; Check : Is32BitOfficeInstalled; AfterInstall : RegisterAddin
48
48
49
49
[UninstallDelete]
50
- ; TODO we may not want to delete everything?...
51
- Name : {app} ; Type : filesandordirs
50
+ ; Removing all application files (except for configuration).
51
+ Name : " {app} \*.dll" ; Type : filesandordirs
52
+ Name : " {app} \*.xml" ; Type : filesandordirs
53
+ Name : " {app} \*.pdb" ; Type : filesandordirs
52
54
53
55
[Run]
54
56
; http://stackoverflow.com/questions/5618337/how-to-register-a-net-dll-using-inno-setup
@@ -72,46 +74,60 @@ Name: "{group}\{cm:UninstallProgram,{#AppName}}"; Filename: "{uninstallexe}"
72
74
const
73
75
SCS_32BIT_BINARY = 0 ;
74
76
SCS_64BIT_BINARY = 6 ;
75
- // There are other values that GetBinaryType can return, but we're
76
- // not interested in them.
77
+ // There are other values that GetBinaryType can return, but we're not interested in them.
78
+ OfficeNotFound = -1 ;
79
+
77
80
var
78
81
HasCheckedOfficeBitness: Boolean;
79
82
OfficeIs64Bit: Boolean;
80
83
81
84
function GetBinaryType (lpApplicationName: AnsiString; var lpBinaryType: Integer): Boolean;
82
85
external ' GetBinaryTypeA@kernel32.dll stdcall' ;
83
86
84
- // TODO this only checks for Excel's bitness, but what if they don't have it installed?
85
- function Is64BitExcelFromRegisteredExe (): Boolean;
87
+ function GetOfficeAppBitness (exeName: string): Integer;
86
88
var
87
- excelPath : String;
89
+ appPath : String;
88
90
binaryType: Integer;
89
91
begin
90
- Result := False; // Default value - assume 32-bit unless proven otherwise.
91
- // RegQueryStringValue second param is '' to get the (default) value for the key
92
- // with no sub-key name, as described at
93
- // http://stackoverflow.com/questions/913938/
94
- if IsWin64() and RegQueryStringValue(HKEY_LOCAL_MACHINE,
95
- ' SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\excel.exe' ,
96
- ' ' , excelPath) then begin
97
- // We've got the path to Excel.
92
+ Result := OfficeNotFound; // Default value.
93
+
94
+ if RegQueryStringValue(HKEY_LOCAL_MACHINE,
95
+ ' SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\' + exeName,
96
+ ' ' , appPath) then begin
98
97
try
99
- if GetBinaryType(excelPath, binaryType) then begin
100
- Result := (binaryType = SCS_64BIT_BINARY);
101
- end ;
98
+ if GetBinaryType(appPath, binaryType) then Result := binaryType;
102
99
except
103
- // Ignore - better just to assume it's 32-bit than to let the installation
104
- // fail. This could fail because the GetBinaryType function is not
105
- // available. I understand it's only available in Windows 2000
106
- // Professional onwards.
107
100
end ;
108
101
end ;
109
102
end ;
110
103
104
+ function GetOfficeBitness (): Integer;
105
+ var
106
+ appBitness: Integer;
107
+ officeExeNames: array [0 ..4 ] of String;
108
+ i: Integer;
109
+ begin
110
+ officeExeNames[0 ] := ' excel.exe' ;
111
+ officeExeNames[1 ] := ' msaccess.exe' ;
112
+ officeExeNames[2 ] := ' winword.exe' ;
113
+ officeExeNames[3 ] := ' outlook.exe' ;
114
+ officeExeNames[4 ] := ' powerpnt.exe' ;
115
+
116
+ for i := 0 to 4 do begin
117
+ appBitness := GetOfficeAppBitness(officeExeNames[i]);
118
+ if appBitness <> OfficeNotFound then begin
119
+ Result := appBitness;
120
+ exit;
121
+ end ;
122
+ end ;
123
+ // Note if we get to here then we haven't found any Office versions. Should
124
+ // we fail the installation?
125
+ end ;
126
+
111
127
function Is64BitOfficeInstalled (): Boolean;
112
128
begin
113
129
if (not HasCheckedOfficeBitness) then
114
- OfficeIs64Bit := Is64BitExcelFromRegisteredExe( );
130
+ OfficeIs64Bit := (GetOfficeBitness() = SCS_64BIT_BINARY );
115
131
Result := OfficeIs64Bit;
116
132
end ;
117
133
@@ -120,12 +136,66 @@ begin
120
136
Result := (not Is64BitOfficeInstalled());
121
137
end ;
122
138
139
+ // http://kynosarges.org/DotNetVersion.html
140
+ function IsDotNetDetected (version: string; service: cardinal): boolean;
141
+ // Indicates whether the specified version and service pack of the .NET Framework is installed.
142
+ //
143
+ // version -- Specify one of these strings for the required .NET Framework version:
144
+ // 'v1.1.4322' .NET Framework 1.1
145
+ // 'v2.0.50727' .NET Framework 2.0
146
+ // 'v3.0' .NET Framework 3.0
147
+ // 'v3.5' .NET Framework 3.5
148
+ // 'v4\Client' .NET Framework 4.0 Client Profile
149
+ // 'v4\Full' .NET Framework 4.0 Full Installation
150
+ // 'v4.5' .NET Framework 4.5
151
+ //
152
+ // service -- Specify any non-negative integer for the required service pack level:
153
+ // 0 No service packs required
154
+ // 1, 2, etc. Service pack 1, 2, etc. required
155
+ var
156
+ key: string;
157
+ install, release, serviceCount: cardinal;
158
+ check45, success: boolean;
159
+ begin
160
+ // .NET 4.5 installs as update to .NET 4.0 Full
161
+ if version = ' v4.5' then begin
162
+ version := ' v4\Full' ;
163
+ check45 := true;
164
+ end else
165
+ check45 := false;
166
+
167
+ // installation key group for all .NET versions
168
+ key := ' SOFTWARE\Microsoft\NET Framework Setup\NDP\' + version;
169
+
170
+ // .NET 3.0 uses value InstallSuccess in subkey Setup
171
+ if Pos(' v3.0' , version) = 1 then begin
172
+ success := RegQueryDWordValue(HKLM, key + ' \Setup' , ' InstallSuccess' , install);
173
+ end else begin
174
+ success := RegQueryDWordValue(HKLM, key, ' Install' , install);
175
+ end ;
176
+
177
+ // .NET 4.0/4.5 uses value Servicing instead of SP
178
+ if Pos(' v4' , version) = 1 then begin
179
+ success := success and RegQueryDWordValue(HKLM, key, ' Servicing' , serviceCount);
180
+ end else begin
181
+ success := success and RegQueryDWordValue(HKLM, key, ' SP' , serviceCount);
182
+ end ;
183
+
184
+ // .NET 4.5 uses additional value Release
185
+ if check45 then begin
186
+ success := success and RegQueryDWordValue(HKLM, key, ' Release' , release);
187
+ success := success and (release >= 378389 );
188
+ end ;
189
+
190
+ result := success and (install = 1 ) and (serviceCount >= service);
191
+ end ;
192
+
123
193
function InitializeSetup (): Boolean;
124
194
var
125
195
iErrorCode: Integer;
126
196
begin
127
- // MS .NET Framework 4.0 must be installed for this application to work.
128
- if Not RegKeyExists(HKLM, ' SOFTWARE\Microsoft\.NETFramework\ v4.0.30319 ' ) then
197
+ // MS .NET Framework 4.5 must be installed for this application to work.
198
+ if not IsDotNetDetected( ' v4.5 ' , 0 ) then
129
199
begin
130
200
MsgBox(ExpandConstant(' {cm:NETFramework40NotInstalled}' ), mbCriticalError, mb_Ok);
131
201
ShellExec(' open' , ' http://msdn.microsoft.com/en-us/netframework/aa731542' , ' ' , ' ' , SW_SHOW, ewNoWait, iErrorCode)
0 commit comments