我有这个自定义代码来检查Microsoft Framework的安装:
function PrepareToInstall(var NeedsRestart: Boolean): String;
var
IsInstalled: Cardinal;
begin
Result := '';
dotNetNeeded := true;
{ Check for required netfx installation }
{ http://msdn.microsoft.com/en-us/library/hh925568%28v=vs.110%29.aspx#net_b }
if(Is64BitInstallMode()) then begin
if (RegValueExists(HKLM, 'SOFTWARE\Wow6432Node\Microsoft\NET Framework Setup\NDP\v4\Full', 'Release')) then begin
RegQueryDWordValue(HKLM, 'SOFTWARE\Wow6432Node\Microsoft\NET Framework Setup\NDP\v4\Full', 'Release', IsInstalled);
if(IsInstalled >= 378675) then begin
dotNetNeeded := false;
downloadNeeded := false;
end;
end;
end
else begin
if (RegValueExists(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full', 'Release')) then begin
RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full', 'Release', IsInstalled);
if(IsInstalled >= 378675) then begin
dotNetNeeded := false;
downloadNeeded := false;
end;
end;
end;
if(dotNetNeeded) then begin
if (not IsAdminLoggedOn()) then begin
Result := ExpandConstant('{cm:DotNet_NeedAdminRights}');
end
else begin
dotnetRedistPath := ExpandConstant('{src}\NDP451-KB2858728-x86-x64-AllOS-ENU.exe');
if not FileExists(dotnetRedistPath) then begin
dotnetRedistPath := ExpandConstant('{tmp}\NDP451-KB2858728-x86-x64-AllOS-ENU.exe');
if not FileExists(dotnetRedistPath) then begin
isxdl_AddFile(dotnetRedistURL, dotnetRedistPath);
downloadNeeded := true;
end;
end;
if (downloadNeeded) then begin
if (MsgBox(ExpandConstant('{cm:DotNet_NeedToDownload}'), mbConfirmation, MB_OKCANCEL) = IDCANCEL) then begin
Result := ExpandConstant('{cm:DotNet_InstallAborted}');
end;
end;
end;
end;
end;
我正在迁移此代码以支持4.6.2框架,因此我可以将下载路径更改为:
http://go.microsoft.com/fwlink/?LinkId=780600
使用文件名:
NDP462-KB3151800-x86-x64-AllOS-ENU.exe
但是,这是注册表检查我有一个问题。根据版本4.6.2的here,密钥的值将为:
在Windows 10周年更新:394802
在所有其他操作系统版本上:394806
我如何在脚本中知道我应该寻找哪个值?或者只使用>= 394802
?
答案 0 :(得分:1)
>= 394802
的测试应该足够好了。
如果您想要安全起见,可以使用它来测试Windows 10周年更新(版本10.0.14393):
GetWindowsVersion >= $A003839