所有的,我知道下面的方法来检查框架版本NSIS。对于.NET4.0 +我目前使用
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"
StrCpy $1 "SOFTWARE\Microsoft\.NETFramework" ; Registry entry to look in.
StrCpy $2 0
StartEnum:
; Enumerate the versions installed.
EnumRegKey $3 HKLM "$1\policy" $2
; If we don't find any versions installed, it's not here.
StrCmp $3 "" noDotNet notEmpty
; We found something.
notEmpty:
; Find out if the RegKey starts with 'v'.
; If it doesn't, goto the next key.
StrCpy $4 $3 1 0
StrCmp $4 "v" +1 goNext
StrCpy $4 $3 1 1
; It starts with 'v'. Now check to see how the installed major version
; relates to our required major version.
; If it's equal check the minor version, if it's greater,
; we found a good RegKey.
IntCmp $4 ${DOT_MAJOR} +1 goNext yesDotNetReg
; Check the minor version. If it's equal or greater to our requested
; version then we're good.
StrCpy $4 $3 1 3
IntCmp $4 ${DOT_MINOR} yesDotNetReg goNext yesDotNetReg
goNext:
; Go to the next RegKey.
IntOp $2 $2 + 1
goto StartEnum
yesDotNetReg:
; Now that we've found a good RegKey, let's make sure it's actually
; installed by getting the install path and checking to see if the
; mscorlib.dll exists.
EnumRegValue $2 HKLM "$1\policy\$3" 0
; $2 should equal whatever comes after the major and minor versions
; (ie, v1.1.4322)
StrCmp $2 "" noDotNet
ReadRegStr $4 HKLM $1 "InstallRoot"
; Hopefully the install root isn't empty.
StrCmp $4 "" noDotNet
; Build the actuall directory path to mscorlib.dll.
StrCpy $4 "$4$3.$2\mscorlib.dll"
IfFileExists $4 yesDotNet noDotNet
noDotNet:
; No, something went wrong along the way. Looks like the
; proper .NET Framework isn't installed.
MessageBox MB_ICONEXCLAMATION "To install UserCost, Microsoft's .NET Framework v${DOT_MAJOR}.${DOT_MINOR} \
(or higher) must be installed. Cannot proceed with the installation!"
${OpenURL} "${WWW_MS_DOTNET4}"
Abort
yesDotNet:
; Everything checks out. Proceed with the rest of the installation.
FunctionEnd
这非常适用于.NET4.0,但现在我已延长我的应用程序能够利用异步
/ 等待
的功能,随后需要用户安装.NET4.5 +。上述方法不适合作为安装为.NET4.5现在不使用regestry路径HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft.NETFramework \策略来存储任何新的信息,即该路径似乎没有持有的值。.NET4.0和4.5之间变化,现在我已经看到了以下职位:
This works very well for .NET4.0, but I have now extended my application to utilise the async
/await
features and subsequently need users to install .NET4.5+. The above method is not suitable as the installation for .NET4.5 now does not use the regestry path 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.NETFramework\Policy" to store any new information, that is that path does not seem to hold a value that changes between .NET4.0 and 4.5. Now I have seen the following posts:
NSIS安装程序与.NET 4.5
,它使用注册表路径/项HKEY_LOCAL_MACHINE \ SOFTWARE \微软\ NET Framework安装\新民主党做检查。现在,这个也做机器人工作的条目不改变从.NET4.0至4.5。我注意到,有和进入所谓的HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft.NETFramework \ v4.0.30319 \ SKUs.NETFramework,版本= V4.5我可以用它来总是检查Framework版本?
which uses the registry path/entry 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP' to do the checks. Now this also does bot work as the entry does not change from .NET4.0 to 4.5. I notice that there is and entry called 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.NETFramework\v4.0.30319\SKUs.NETFramework,Version=v4.5' can I use this to check the Framework version invariably?
时的全过程中的一个官方线采用NSIS检查.NET4.5?
Is there an offical line of the way to check for .NET4.5 using NSIS?
感谢您的时间。
注:随后一些安装.NET4.5我的用户已经进行有针对的注册表值的
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full
的发布
DWORD值不是 378389
,但 378181
。此更改似乎解决问题作为发布
的项目不是在注册表中.NET4.5及以下。的
a DWORD value named Release
was not 378389
but 378181
. Making this change seemed to resolve the problem as the entry for the Release
is not in the registry for .NET4.5 and below.
是有一个的官方的方式来检查是否安装了.NET Framework 4.5,即使它不是一个真正的友好。从 MSDN :
Yes there is an official way to check if .NET Framework 4.5 is installed, even if it's not really friendly. From MSDN:
您可以测试是否在.NET Framework 4.5或.NET Framework 4通过检查 HKEY_LOCAL_MACHINE \ SOFTWARE \微软\ NET Framework安装\新民主党\ V4 \全部子项在注册表中名为
DWORD
值发布
。这个 DWORD
的存在表明,在.NET Framework 4.5已经安装在该计算机上。推出的值是一个版本号。要确定是否安装了.NET Framework 4.5的最终发行版本,检查一个值等于或大于378389。
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
这意味着你首先要检查,如果4.0安装,然后检查是否有发布
在 HKEY_LOCAL_MACHINE \ SOFTWARE \微软命名的值\ NET Framework安装\新民主党\ V4 \全部
,如果是的话,4.5已经安装了(我想你可以跳过检查为pre-发布版本)。
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).
编辑:查看this帖子这里SO有关检测其他已安装的.NET版本的详细信息。
check this post here on SO for details about detecting other installed .NET versions.