此repository提供了有关部署.NET Microsoft Framework的指南。
我的Inno Setup脚本中有代码来检测是否安装了.NET Framework。这是我的功能:
function PrepareToInstall(var NeedsRestart: Boolean): String;
begin
result := '';
dotNetNeeded := not IsDotNetDetected();
if(dotNetNeeded) then begin
if (MsgBox(ExpandConstant('{cm:DotNet_NeedToDownload}'), \
mbConfirmation, MB_OKCANCEL) = IDCANCEL) then begin
result := ExpandConstant('{cm:DotNet_InstallAborted}');
Abort();
end;
end;
end;
// Determines if .NET 4.6.2 (or higher) is installed
function IsDotNetDetected(): boolean;
var
strKey64: string;
strKey86: string;
release: cardinal;
success: boolean;
dwInstalled: cardinal;
begin
strKey64 := 'SOFTWARE\Wow6432Node\Microsoft\NET Framework Setup\NDP\v4\Full';
strKey86 := 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full';
result := false; // Assume .NET Framework 4.6.2 is not installed
// For more information, see:
// http://msdn.microsoft.com/en-us/library/hh925568%28v=vs.110%29.aspx#net_b
if(Is64BitInstallMode()) then begin
if (RegValueExists(HKLM, strKey64, 'Release')) then begin
RegQueryDWordValue(HKLM, strKey64, 'Release', dwInstalled);
if(dwInstalled >= 378675) then begin
result := true;
end;
end;
end
else begin
if (RegValueExists(HKLM, strKey86, 'Release')) then begin
RegQueryDWordValue(HKLM, strKey86, 'Release', dwInstalled);
if(dwInstalled >= 378675) then begin
result := true;
end;
end;
end;
end;
我遇到了GitHub {{3}}
它具有以下功能:
// determines if .NET 4.7 is installed
function IsDotNetDetected(): boolean;
var
key: string;
release: cardinal;
success: boolean;
install: cardinal;
begin
key := 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full';
// check if the install bit is set
success := RegQueryDWordValue(HKLM, key, 'Install', install);
// and that the release number is greater than 460805, which is the version
// that's bundled into the installer
success := success and RegQueryDWordValue(HKLM, key, 'Release', release);
success := success and (release >= 460805);
result := success
end;
他们不检查Wow6432Node
。那我要检查太多注册表项吗?