Created
April 26, 2018 02:04
-
-
Save rwilkes/c0602929006effc9daab773a44b20551 to your computer and use it in GitHub Desktop.
.Net tools for InnoSetup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Code] | |
{ | |
// http://www.kynosarges.de/DotNetVersion.html | |
Indicates whether the specified version and service pack of the .NET Framework is installed. | |
version -- Specify one of these strings for the required .NET Framework version: | |
'v1.1.4322' .NET Framework 1.1 | |
'v2.0.50727' .NET Framework 2.0 | |
'v3.0' .NET Framework 3.0 | |
'v3.5' .NET Framework 3.5 | |
'v4\Client' .NET Framework 4.0 Client Profile | |
'v4\Full' .NET Framework 4.0 Full Installation | |
'v4.5' .NET Framework 4.5 | |
service -- Specify any non-negative integer for the required service pack level: | |
0 No service packs required | |
1, 2, etc. Service pack 1, 2, etc. required | |
} | |
function DotNetIsDetected(version :String; service :Cardinal) :boolean; | |
var | |
key: String; | |
install, release, serviceCount :Cardinal; | |
check45, success :Boolean; | |
begin | |
// .NET 4.5 installs as update to .NET 4.0 Full | |
if version = 'v4.5' then begin | |
version := 'v4\Full'; | |
check45 := true; | |
end else | |
check45 := false; | |
Log('Check DotNet version'); | |
// installation key group for all .NET versions | |
key := 'SOFTWARE\Microsoft\NET Framework Setup\NDP\' + version; | |
// .NET 3.0 uses value InstallSuccess in subkey Setup | |
if Pos('v3.0', version) = 1 then begin | |
success := RegQueryDWordValue(HKLM, key + '\Setup', 'InstallSuccess', install); | |
end else begin | |
success := RegQueryDWordValue(HKLM, key, 'Install', install); | |
end; | |
// .NET 4.0/4.5 uses value Servicing instead of SP | |
if Pos('v4', version) = 1 then begin | |
success := success and RegQueryDWordValue(HKLM, key, 'Servicing', serviceCount); | |
end else begin | |
success := success and RegQueryDWordValue(HKLM, key, 'SP', serviceCount); | |
end; | |
// .NET 4.5 uses additional value Release | |
if check45 then begin | |
success := success and RegQueryDWordValue(HKLM, key, 'Release', release); | |
success := success and (release >= 378389); | |
end; | |
Result := success and (install = 1) and (serviceCount >= service); | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment