所有的,我知道以下方法检查NSIS中的框架版本。对于.NET4.0 +我目前使用使用NSIS检查.NET4.5 +
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,但现在我已经延长我的应用程序利用async
/await
功能,随后需要用户安装.NET4.5 +。上述方法不适用,因为.NET4.5的安装现在不使用regestry路径“HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft.NETFramework \ Policy”来存储任何新信息,即该路径似乎不具有值.NET4.0和4.5之间的变化现在我已经看到了以下职位:
它使用的注册表路径/进入“HKEY_LOCAL_MACHINE \ SOFTWARE \微软\ NET Framework安装\ NDP”做检查。现在,这也是机器人的工作,因为入口不会从.NET4.0更改为4.5。我注意到有和称为'HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft.NETFramework \ v4.0.30319 \ SKUs.NETFramework,版本= v4的条目。 5'我可以用它来检查框架版本吗?
是否有使用NSIS检查.NET4.5的方法的一条主线?
谢谢你的时间。
注:随后一些安装.NET4.5我的用户已经执行有注册表值
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full
命名为Release
一个DWORD值不378389
,但378181
。进行此更改似乎可以解决问题,因为Release
的条目不在.NET4.5及更低版本的注册表中。
这是一个高质量的答案。这些信息在哪里由微软提供 - 或者我们是否期望找到自己的信息?感谢您的时间... – MoonKnight 2013-03-05 15:42:03
我忘了引用[源代码](http://msdn.microsoft.com/en-us/library/hh925568.aspx)。 – 2013-03-05 15:44:47
刚刚找到它。再次感谢... – MoonKnight 2013-03-05 15:49:20