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"; ...
随机推荐
- Maven的使用--Eclipse在线安装Maven插件m2e
我使用的Eclipse版本是3.7(Indigo) 通过Eclipse的help选项,点击“Install New Software...”弹出安装对话框, 点击add按钮,在Location里输入h ...
- 处理事件的方式:两种类的覆盖处理(自己管理,覆盖专用事件函数;自己统一管理,覆盖QWidget::Event通用函数),一种对象的处理(父控件统一管理,即安装过滤器),两种全局处理(QCoreApplication安装过滤器;覆盖notify方法)
虽然只有一句话,但却是我自己的心得. 特别注意,bool QCoreApplication::notify(QObject *receiver, QEvent *event) 明确指明了要发送的对象, ...
- 用JSON 和 Google 实现全文翻译
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ...
- iOS开发之property属性介绍
大家都知道@property和@synthesize可以自动生成某个类成员变量的存取方法,但可能对property中的一些属性不是很了解,网上的一些介绍有的不是很正确,感觉会误导新手,于是准备详细介绍 ...
- < IOS > IOS适配,简单的分析解决一下
版权:张英堂 欢迎转载,转载请注明出处. 做的项目很多,一到适配的时候头就大了,IOS6,7的适配,屏幕的适配,当然还有下一步要出4.7屏幕,也要做适配....悲剧的移动端的人员. 怎么做一个通用的适 ...
- UESTC_菲波拉契数制 2015 UESTC Training for Dynamic Programming<Problem E>
E - 菲波拉契数制 Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) Submi ...
- UESTC_方老师买表 CDOJ 885
老师买表 Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) Submit Stat ...
- TCP/IP协议详解概述
TCP/IP协议详解卷1--第一章概述--读书笔记 作者:vpoet 日期:2015/06/25 注:本系列的文章只是作者对TCP/IP协议的理解,难免会出现纰漏或者不完整,当然也有可能很肤浅,希望大 ...
- 分享几种Linux软件的安装方法
Linux软件安装由于不同的Linux分支,安装方法也互不相同,介绍几种常见的安装方法. 1. 源码安装, 对于本身具有开源血统的Linux系统来说,几乎所有的开源软件都支持在Linux平台运 ...
- 【巧妙预处理系列+离散化处理】【uva1382】Distant Galaxy
给出平面上的n个点,找一个矩形,使得边界上包含尽量多的点. [输入格式] 输入的第一行为数据组数T.每组数据的第一行为整数n(1≤n≤100):以下n行每行两个整数,即各个点的坐标(坐标均为绝对值不超 ...