to retrieve the current version of the .NET Framework, you can use this code:
Code: Select all
function GetLatestVersion4() as string
local cReturn as string
local oMainKey as RegistryKey
local oKey as RegistryKey
local nClientRelease as int
local nFullRelease as int
local cClientVersion as string
local cFullVersion as string
local nRelease as int
local cVersion as string
cReturn := ""
oMainKey := RegistryKey.OpenBaseKey( RegistryHive.LocalMachine, RegistryView.Default )
oKey := oMainKey:OpenSubKey( "SOFTWAREMicrosoftNET Framework SetupNDPv4Client" )
nClientRelease := ( int ) oKey:GetValue( "Release", 0 )
cClientVersion := ( string ) oKey:GetValue( "Version", "" )
oKey:Dispose()
oKey := null
oKey := oMainKey:OpenSubKey( "SOFTWAREMicrosoftNET Framework SetupNDPv4Full" )
nFullRelease := ( int ) oKey:GetValue( "Release", 0 )
cFullVersion := ( string ) oKey:GetValue( "Version", "" )
oKey:Dispose()
oKey := null
oMainKey:Dispose()
oMainKey := null
if nFullRelease > nClientRelease
nRelease := nFullRelease
else
nRelease := nClientRelease
endif
if cFullVersion > cClientVersion
cVersion := cFullVersion
else
cVersion := cClientVersion
endif
do case
case nRelease == 0
cReturn := cVersion
case nRelease == 378389
cReturn := ".NET Framework 4.5"
case nRelease == 378675
cReturn := ".NET Framework 4.5.1 - Windows 8.1"
case nRelease == 378758
cReturn := ".NET Framework 4.5.1 - Windows 8, Windows 7 SP1, Windows Vista SP2"
case nRelease == 379893
cReturn := ".NET Framework 4.5.2"
case nRelease == 393295
cReturn := ".NET Framework 4.6 - Windows 10"
case nRelease == 393297
cReturn := ".NET Framework 4.6 - other"
case nRelease == 394254
cReturn := ".NET Framework 4.6.1 - Windows 10"
case nRelease == 394271
cReturn := ".NET Framework 4.6.1 - other"
case nRelease == 394802
cReturn := ".NET Framework 4.6.2 - Windows 10 Anniversary Update"
case nRelease == 394806
cReturn := ".NET Framework 4.6.2 - other"
case nRelease == 460798
cReturn := ".NET Framework 4.7 - Windows 10 Creators Update"
case nRelease == 460805
cReturn := ".NET Framework 4.7 - other"
case nRelease == 461308
cReturn := ".NET Framework 4.7.1 - Windows 10 Fall Creators Update"
case nRelease == 461310
cReturn := ".NET Framework 4.7.1 - other"
case nRelease == 461808
cReturn := ".NET Framework 4.7.2 - Windows 10 April 2018 Update"
case nRelease == 461814
cReturn := ".NET Framework 4.7.2 - other"
otherwise
cReturn := ".NET Framework " + nRelease:ToString()
endcase
return cReturn