Check .NET Version with Inno Setup
原文 http://www.kynosarges.org/DotNetVersion.html
Inno Setup by Jordan Russell is a great installation scripting program, but lacks a built-in function to determine the .NET Framework version installed on the target machine. Fortunately, it’s easy to write such a function using Inno Setup’s Pascal scripting language.
Microsoft maintains a set of registry keys that indicate the installed .NET Framework versions and service packs. C# MVP Scott Dorman has posted a list comprising versions 1.0 through 4.0 (at the time of this writing) in this Stack Overflow thread. The required registry keys are quite similar for most .NET Framework versions except 1.0. We’ll ignore that version which has been obsoleted by 1.1 anyway.
Version 4.5 is somewhat tricky since it installs as an in-place update for version 4.0 and reuses the exact same registry keys. The MSDN page How to: Determine Which .NET Framework Versions Are Installed suggests checking for the presence of DWORD
value Release
, so that’s what I’m doing below. An alternative would be to examine the REG_SZ
value Version
which equals 4.0.30319 for .NET 4.0 and 4.5.50709 for .NET 4.5.
The Script
In the following Inno Setup scripting code block, function IsDotNetDetected
checks whether the specified .NET Framework version and at least the specified service pack level are installed. All listed version strings are for final release versions; betas and release candidates typically have different version numbers. Function InitializeSetup
demonstrates how to use IsDotNetDetected
to check for .NET Framework 4.0 Client Profile without service packs.
I’m placing this small bit of code in the public domain, so you may embed it in your own projects as you see fit.
[Code]
function IsDotNetDetected(version: string; service: cardinal): boolean;
// Indicates whether the specified version and service pack of the .NET Framework is installed.
//
// version -- Specify one of these strings for the required .NET Framework version:
// 'v1.1.4322' .NET Framework 1.1
// 'v2.0.50727' .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
//
// service -- Specify any non-negative integer for the required service pack level:
// 0 No service packs required
// 1, 2, etc. Service pack 1, 2, etc. required
var
key: string;
install, release, serviceCount: cardinal;
check45, success: boolean;
begin
// .NET 4.5 installs as update to .NET 4.0 Full
if version = 'v4.5' then begin
version := 'v4\Full';
check45 := true;
end else
check45 := false; // installation key group for all .NET versions
key := 'SOFTWARE\Microsoft\NET Framework Setup\NDP\' + version; // .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/4.5 uses 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 uses additional value Release
if check45 then begin
success := success and RegQueryDWordValue(HKLM, key, 'Release', release);
success := success and (release >= 378389);
end; result := success and (install = 1) and (serviceCount >= service);
end; function InitializeSetup(): Boolean;
begin
if not IsDotNetDetected('v4\Client', 0) then begin
MsgBox('MyApp requires Microsoft .NET Framework 4.0 Client Profile.'#13#13
'Please use Windows Update to install this version,'#13
'and then re-run the MyApp setup program.', mbInformation, MB_OK);
result := false;
end else
result := true;
end;
Check .NET Version with Inno Setup的更多相关文章
- Inno setup: check for new updates
Since you've decided to use a common version string pattern, you'll need a function which will parse ...
- inno setup介绍及官方网站地址
使 用 笔 记 1.Inno Setup 是什么?Inno Setup 是一个免费的 Windows 安装程序制作软件.第一次发表是在 1997 年,Inno Setup 今天在功能设置和稳定性上的竞 ...
- [!!!!!]Inno Setup教程-常见问题解答
[转]Inno Setup教程-常见问题解答 功能 * 翻译 Inno Setup 文字 * 它支持 MBCS (多字节字符集) 吗? * 将来会支持 Windows Installer 吗? ...
- inno setup 打包
; -- Example1.iss -- ; Demonstrates copying files and creating an icon. ; SEE THE DOCUMENTATION FOR ...
- INNO setup 制作安装包
1.获取SQLserver安装路径vardbpath:string;rtn:boolean;rtn := RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWA ...
- 注册flash.ocx inno setup (转)
; 脚本由 Inno Setup 脚本向导 生成! ; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档! #define MyAppName "xx模块" #de ...
- 用Inno Setup制作WEB程序安装包
原文 用Inno Setup制作WEB程序安装包 最近做了一个WEB程序的安装包,我把制作的过程做个介绍,贴出源码给大家做个参考 看看inno 的脚本 [Setup] AppCopyright=tes ...
- Inno Setup Pascal Script to search for running process
I am currently trying to do a validation at the uninstall moment. In a Pascal script function, in In ...
- Inno Setup 注册表启动项 修改注册表
//注册表启动项 [Registry] Root: HKLM; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ...
随机推荐
- 手机天猫nba项目总结
页面逻辑: 技术统计 比赛竞猜 猜你喜欢 进入页面时,获取服务器的当前时间.然后进行页面上的每秒递增.1.每隔n秒向后台发送请求,获取最新比分信息,球队图像,球员信息.然后更改页面.2.每隔n秒向后台 ...
- Shell使用
http://www.cnblogs.com/hbt19860104/archive/2012/08/14/2638952.html http://blog.csdn.net/tttyd/articl ...
- I2C串行总线标准驱动程序(C51)-万能程序
#include "reg51.h" #include "intrins.h" unsigned char SystemError; sbit SCL= P1^ ...
- 微软的OneDrive研究~
Dropbox 很好,唯一觉得不爽的是只能同步指定的目录.不过被墙之后就不那么方便了,所以改用微软的 Live Mesh,缺点是支持的设备少(仅 PC 和 Mac). https://technet. ...
- 认识元数据和IL(上) <第三篇>
说在,开篇之前 很早就有说说Metadata(元数据)和IL(中间语言)的想法了,一直在这篇开始才算脚踏实地的对这两个阶级兄弟投去些细关怀,虽然来得没有<第一回:恩怨情仇:is和as>那么 ...
- git与svn的使用比较
先说下基础知识: git是本地会(维护)有个版本仓库. svn本地也会维护一个自己的信息(一般是目录结构和文件状态的信息),这里的文件状态一般是指:文件是已删除,还是已添加,还是被修改等等.一般是会有 ...
- Linux系统编程(15)——shell脚本语法
Shell字符串 字符串是shell编程中最常用最有用的数据类型(除了数字和字符串,也没啥其它类型好用了),字符串可以用单引号,也可以用双引号,也可以不用引号.单双引号的区别跟PHP类似. 单引号 s ...
- java 8 中lambda表达式学习
转自 http://blog.csdn.net/renfufei/article/details/24600507 http://www.jdon.com/idea/java/10-example-o ...
- 【转】C++容器类
C++容器类 C++中的容器类包括“顺序存储结构”和“关联存储结构”,前者包括vector,list,deque等:后者包括set,map,multiset,multimap等. 若需要存储的元素数在 ...
- 一款超出你想象的代码审阅软件understand
看源码人们一般会想到source insight这款软件可是这款软件目前只支持windows平台,那如果我想在Linux平台上审阅代码呢, 没关系还有一款强大的软件understand,这款软件能够生 ...