Check for .NET4.5+ with NSIS

前端 未结 6 1956
暗喜
暗喜 2020-12-28 20:22

All, I am aware of the following methods to check the framework version in NSIS. For .NET4.0+ I currently use

Function IsDotNetInstalled

    StrCpy $0 \"0\         


        
6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-28 21:12

    Yes there is an official way to check if .NET Framework 4.5 is installed, even if it's not really friendly. From MSDN:

    You can test whether the .NET Framework 4.5 or the .NET Framework 4 is installed by checking the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full subkey in the registry for a DWORD value named Release. The existence of this DWORD indicates that the .NET Framework 4.5 has been installed on that computer. The value of Release is a version number. To determine if the final release version of the .NET Framework 4.5 is installed, check for a value that is equal to or greater than 378389.

    http://msdn.microsoft.com/en-us/library/hh925568.aspx

    It means you first have to check if 4.0 is installed and then to check if there is a value named Release in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full, if so then 4.5 is already installed (I think you can skip the check for a pre-release version).

    EDIT: check this post here on SO for details about detecting older installed .NET versions and this MSDN article to distinguish between for 4.5.x versions.

提交回复
热议问题