Skip to content

Commit e8d2104

Browse files
author
Ross Knudsen
committed
Added code to check version of .Net is 4.5.
1 parent 63d0078 commit e8d2104

File tree

1 file changed

+56
-2
lines changed

1 file changed

+56
-2
lines changed

Installer Build Script.iss

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,66 @@ begin
122122
Result := (not Is64BitOfficeInstalled());
123123
end;
124124
125+
// http://kynosarges.org/DotNetVersion.html
126+
function IsDotNetDetected(version: string; service: cardinal): boolean;
127+
// Indicates whether the specified version and service pack of the .NET Framework is installed.
128+
//
129+
// version -- Specify one of these strings for the required .NET Framework version:
130+
// 'v1.1.4322' .NET Framework 1.1
131+
// 'v2.0.50727' .NET Framework 2.0
132+
// 'v3.0' .NET Framework 3.0
133+
// 'v3.5' .NET Framework 3.5
134+
// 'v4\Client' .NET Framework 4.0 Client Profile
135+
// 'v4\Full' .NET Framework 4.0 Full Installation
136+
// 'v4.5' .NET Framework 4.5
137+
//
138+
// service -- Specify any non-negative integer for the required service pack level:
139+
// 0 No service packs required
140+
// 1, 2, etc. Service pack 1, 2, etc. required
141+
var
142+
key: string;
143+
install, release, serviceCount: cardinal;
144+
check45, success: boolean;
145+
begin
146+
// .NET 4.5 installs as update to .NET 4.0 Full
147+
if version = 'v4.5' then begin
148+
version := 'v4\Full';
149+
check45 := true;
150+
end else
151+
check45 := false;
152+
153+
// installation key group for all .NET versions
154+
key := 'SOFTWARE\Microsoft\NET Framework Setup\NDP\' + version;
155+
156+
// .NET 3.0 uses value InstallSuccess in subkey Setup
157+
if Pos('v3.0', version) = 1 then begin
158+
success := RegQueryDWordValue(HKLM, key + '\Setup', 'InstallSuccess', install);
159+
end else begin
160+
success := RegQueryDWordValue(HKLM, key, 'Install', install);
161+
end;
162+
163+
// .NET 4.0/4.5 uses value Servicing instead of SP
164+
if Pos('v4', version) = 1 then begin
165+
success := success and RegQueryDWordValue(HKLM, key, 'Servicing', serviceCount);
166+
end else begin
167+
success := success and RegQueryDWordValue(HKLM, key, 'SP', serviceCount);
168+
end;
169+
170+
// .NET 4.5 uses additional value Release
171+
if check45 then begin
172+
success := success and RegQueryDWordValue(HKLM, key, 'Release', release);
173+
success := success and (release >= 378389);
174+
end;
175+
176+
result := success and (install = 1) and (serviceCount >= service);
177+
end;
178+
125179
function InitializeSetup(): Boolean;
126180
var
127181
iErrorCode: Integer;
128182
begin
129-
// MS .NET Framework 4.0 must be installed for this application to work.
130-
if Not RegKeyExists(HKLM, 'SOFTWARE\Microsoft\.NETFramework\v4.0.30319') then
183+
// MS .NET Framework 4.5 must be installed for this application to work.
184+
if not IsDotNetDetected('v4.5', 0) then
131185
begin
132186
MsgBox(ExpandConstant('{cm:NETFramework40NotInstalled}'), mbCriticalError, mb_Ok);
133187
ShellExec('open', 'http://msdn.microsoft.com/en-us/netframework/aa731542', '', '', SW_SHOW, ewNoWait, iErrorCode)

0 commit comments

Comments
 (0)