您的位置 首页 > 数码极客

(如何选择framework版本号)检查.net framework版本号

根据网上前人判断.net版本改加入windows版本判断而来。已测试通过!



; 脚本由 Inno Setup 脚本向导 生成!; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!


[Code] //.net framework安装检查 —— 判断指定的.NET Framework版本及service pack是否已经安装// 函数参数说明:// 参数1:version -- 指定待判断的.NET Framework版本【下面列举了对应关系】:// 'v1.1' .NET Framework 1.1// 'v2.0' .NET Framework 2.0// 'v3.0' .NET Framework 3.0// 'v3.5' .NET Framework 3.5// 'v4\Client' .NET Framework 4.0 Client Profile// 'v4\Full' .NET Framework 4.0 Full Installation// 'v4.5' .NET Framework 4.5// 'v4.5.1' .NET Framework 4.5.1// 'v4.5.2' .NET Framework 4.5.2// 'v4.6' .NET Framework 4.6// 'v4.6.1' .NET Framework 4.6.1// 'v4.6.2' .NET Framework 4.6.2// 'v4.7' .NET Framework 4.7// 'v4.7.1' .NET Framework 4.7.1// 'v4.7.2' .NET Framework 4.7.2// `v4.8` .NET Framework 4.8//// 参数2:service -- 指定待判断的service pack版本:// 0 No service packs required// 1, 2, etc. Service pack 1, 2, etc. requiredfunction IsDotNetDetected(version: string; service: cardinal): boolean;var key, versionKey: string; install, release, serviceCount, versionRelease: cardinal; success: boolean;begin versionKey := version; versionRelease := 0; // .NET 1.1 and 2.0 embed release number in version key if version = 'v1.1' then begin versionKey := 'v1.1.4322'; end else if version = 'v2.0' then begin versionKey := 'v2.0.50727'; end // .NET 4.5 and newer install as update to .NET 4.0 Full else if Pos('v4.', version) = 1 then begin versionKey := 'v4\Full'; case version of 'v4.5': versionRelease := 378389; 'v4.5.1': versionRelease := 378675; // 378758 on Windows 8 and older 'v4.5.2': versionRelease := 379893; 'v4.6': versionRelease := 393295; // 393297 on Windows 8.1 and older 'v4.6.1': versionRelease := 394254; // 394271 before Win10 November Update 'v4.6.2': versionRelease := 394802; // 394806 before Win10 Anniversary Update 'v4.7': versionRelease := 460798; // 460805 before Win10 Creators Update 'v4.7.1': versionRelease := 461308; // 461310 before Win10 Fall Creators Update 'v4.7.2': versionRelease := 461808; // 461814 before Win10 April 2018 Update 'v4.8': versionRelease := 528040; end; end; // installation key group for all .NET versions key := 'SOFTWARE\Microsoft\NET Framework Setup\NDP\' + versionKey; // .NET 3.0 uses value InstallSuccess in subkey Setup if Pos('v3.0', version) = 1 then begin success := RegQueryDWordValue(HKLM, key + '\Setup', 'InstallSuccess', install); end else begin success := RegQueryDWordValue(HKLM, key, 'Install', install); end; // .NET 4.0 and newer use value Servicing instead of SP if Pos('v4', version) = 1 then begin success := success and RegQueryDWordValue(HKLM, key, 'Servicing', serviceCount); end else begin success := success and RegQueryDWordValue(HKLM, key, 'SP', serviceCount); end; // .NET 4.5 and newer use additional value Release if versionRelease > 0 then begin success := success and RegQueryDWordValue(HKLM, key, 'Release', release); success := success and (release >= versionRelease); end; result := success and (install = 1) and (serviceCount >= service);end;//判断windows版本function MyGetWindowsVersion: String; // 获取 Windows 版本varVersion: TWindowsVersion;beginGetWindowsVersionEx(Version);// Windows7if = 6) and = 0) thenbeginResult := 'VISTA';Exit;end;// Windows7if = 6) and = 1) thenbeginResult := 'WIN7';Exit;end;// Windows XP if = 5) and >=1) thenbeginResult := 'WINXP';Exit;end;// Windows 8 if = 6) and >1) thenbeginResult := 'WIN8';Exit;end;// Windows 10if = 10) thenbeginResult := 'WIN10';Exit;end; end; // 根据不同windows版本,判断所需的.netframework版本 function InitializeSetup: Boolean; var Path:string; ResultCode: Integer; Version: TWindowsVersion; begin GetWindowsVersionEx(Version); if (MyGetWindowsVersion='XP' ) then //或者 = 5) begin if IsDotNetDetected('v4', 0) then begin Result := true; End Else begin if MsgBox('系统检测到您没有安装.Net Framework 4 版本,是否立刻下载并安装?', mbConfirmation, MB_YESNO) = idYes then begin Path := ExpandConstant('{pf}/Internet Explorer;); Exec(Path, ';, '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode); MsgBox('请安装好.Net Framework环境后),再运行本安装包程序!',mbInformation,MB_OK); Result := false; Exit; End Else begin MsgBox('没有安装.Net Framework环境,无法运行程序,本安装程序即将退出!',mbInformation,MB_OK); Result := false; Exit; end; end; end else begin Result := true; End; if (MyGetWindowsVersion='WIN7' ) OR (MyGetWindowsVersion='VISTA' ) OR (MyGetWindowsVersion='WIN8' ) then //或者 = 6) begin if IsDotNetDetected('v4.5', 0) or IsDotNetDetected('v4.5.1', 0) or IsDotNetDetected('v4.5.2', 0) or IsDotNetDetected('v4.6', 0) or IsDotNetDetected('v4.6.1', 0) or IsDotNetDetected('v4.6.2', 0) or IsDotNetDetected('v4.7', 0) or IsDotNetDetected('v4.7.1', 0) or IsDotNetDetected('v4.7.2', 0) then begin Result := true; End Else begin if MsgBox('系统检测到您没有安装.Net Framework 4.5-4.7.2版本,是否立刻下载并安装?', mbConfirmation, MB_YESNO) = idYes then begin Path := ExpandConstant('{pf}/Internet Explorer;); Exec(Path, ';, '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode); MsgBox('请安装好.Net Framework环境后),再运行本安装包程序!',mbInformation,MB_OK); Result := false; Exit; End Else begin MsgBox('没有安装.Net Framework环境,无法运行程序,本安装程序即将退出!',mbInformation,MB_OK); Result := false; Exit; end; end; end else begin Result := true; End; if (MyGetWindowsVersion='10' ) then //或者 = 10) begin if IsDotNetDetected('v4.6.1', 0) or IsDotNetDetected('v4.6.2', 0) or IsDotNetDetected('v4.7', 0) or IsDotNetDetected('v4.7.1', 0) or IsDotNetDetected('v4.7.2', 0) then begin Result := true; End Else begin if MsgBox('系统检测到您没有安装.Net Framework 4.6.1-4.8版本,是否立刻下载并安装?', mbConfirmation, MB_YESNO) = idYes then begin Path := ExpandConstant('{pf}/Internet Explorer;); Exec(Path, ';, '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode); MsgBox('请安装好.Net Framework环境后),再运行本安装包程序!',mbInformation,MB_OK); Result := false; Exit; End Else begin MsgBox('没有安装.Net Framework环境,无法运行程序,本安装程序即将退出!',mbInformation,MB_OK); Result := false; Exit; end; end; end else begin Result := true; End; end;

责任编辑: 鲁达

1.内容基于多重复合算法人工智能语言模型创作,旨在以深度学习研究为目的传播信息知识,内容观点与本网站无关,反馈举报请
2.仅供读者参考,本网站未对该内容进行证实,对其原创性、真实性、完整性、及时性不作任何保证;
3.本站属于非营利性站点无毒无广告,请读者放心使用!

“如何选择framework版本号,检查.net,framework版本号,ios制作framework版本号,net,framework最新版本号”边界阅读