Inno Setup 软件封装
例子:
; 脚本用 Inno Setup 脚本向导 生成。
; 查阅文档获取创建 INNO SETUP 脚本文件的详细资料! #define MyAppName "隧道照明系统客户端程序"
#define MyAppVersion "1.5"
#define MyAppPublisher "深圳市泰达鑫信息科技有限公司"
#define MyAppURL "http://www.tdx-it.com/"
#define MyAppExeName "TunnelLighting.exe" [Setup]
; 注意: AppId 的值是唯一识别这个程序的标志。
; 不要在其他程序中使用相同的 AppId 值。
; (在编译器中点击菜单“工具 -> 产生 GUID”可以产生一个新的 GUID)
AppId={{71C8E092-1FB6-43ED-B5A4-CDD9281CC72D}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DisableDirPage=yes
DefaultGroupName={#MyAppName}
LicenseFile=D:\InstallPackage\Client\License.txt
InfoAfterFile=D:\InstallPackage\Client\UpdateLog.txt.txt
OutputDir=D:\InstallPackage
OutputBaseFilename=TunnelLight
SetupIconFile=D:\InstallPackage\Server\InstallIcon.ico
Compression=lzma
SolidCompression=yes [Languages]
Name: "default"; MessagesFile: "compiler:Default.isl"
Name: "chinesesimp"; MessagesFile: "compiler:Languages\ChineseSimp.isl"
Name: "english"; MessagesFile: "compiler:Languages\English.isl" [Messages]
BeveledLabel={#MyAppPublisher}
ConfirmUninstall=您真的想要从电脑中卸载ISsample吗?%n%n按 [是] 则完全删除 % 以及它的所有组件;%n按 [否]则让软件继续留在您的电脑上. [Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags:checkablealone
;unchecked [Files]
Source: "D:\Program Files\Inno Setup 5\Plugins\ISXDL.dll"; Flags: dontcopy
Source: "D:\InstallPackage\Client\TunnelLighting.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\InstallPackage\Client\Aga.Controls.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\InstallPackage\Client\Base.Common.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\InstallPackage\Client\Base.Common.pdb"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\InstallPackage\Client\Base.Controller.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\InstallPackage\Client\Base.Controller.pdb"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\InstallPackage\Client\Base.Dal.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\InstallPackage\Client\Base.Dal.pdb"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\InstallPackage\Client\Base.Model.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\InstallPackage\Client\Base.Model.pdb"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\InstallPackage\Client\License.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\InstallPackage\Client\TunnelLighting.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\InstallPackage\Client\TunnelLighting.exe.config"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\InstallPackage\Client\TunnelLighting.pdb"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\InstallPackage\Client\TunnelLighting.vshost.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\InstallPackage\Client\TunnelLighting.vshost.exe.config"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\InstallPackage\Client\TunnelLighting.vshost.exe.manifest"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\InstallPackage\Client\UpdateLog.txt.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\InstallPackage\Client\websocket-sharp.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\InstallPackage\Client\holePic\*"; DestDir: "{app}\holePic"; Flags: ignoreversion recursesubdirs createallsubdirs
; 注意: 不要在任何共享的系统文件使用 "Flags: ignoreversion" [Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon [Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent [Code] var
dotNetDownloadNeeded: boolean;
dotNetLocalPath:string; procedure isxdl_AddFile(URL, Filename: PAnsiChar);
external 'isxdl_AddFile@files:isxdl.dll stdcall';
function isxdl_DownloadFiles(hWnd: Integer): Integer;
external 'isxdl_DownloadFiles@files:isxdl.dll stdcall';
function isxdl_SetOption(Option, Value: PAnsiChar): Integer;
external 'isxdl_SetOption@files:isxdl.dll stdcall'; function DoInstallDotNet():boolean;
var
hWnd: Integer;
ResultCode: Integer;
begin
result := true;
hWnd := StrToInt(ExpandConstant('{wizardhwnd}')); // don’t try to init isxdl if it’s not needed because it will error on < ie 3
if dotNetDownloadNeeded then begin
isxdl_SetOption('label', '正在下载 Microsoft .NET Framework');
isxdl_SetOption('des-c-r-i-p-tion', '您还未安装Microsoft .NET Framework. 请您耐心等待几分钟,下载完成后会安装到您的的计算机中。');
if isxdl_DownloadFiles(hWnd) = then result := false;
end; if result = true then begin
if Exec(ExpandConstant(dotNetLocalPath), '/qb', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then begin
// handle success if necessary; ResultCode contains the exit code
if not (ResultCode = ) then begin
result := false;
end;
end else begin
// handle failure if necessary; ResultCode contains the error code
result := false;
end;
end; end; //执行安装.net framework function PreInstallDotNet(dotNetName:string;dotNetDownloadUrl:string):boolean;
begin
if (not IsAdminLoggedOn()) then begin
MsgBox('您电脑安装 Microsoft .NET Framework 需要管理员权限', mbInformation, MB_OK);
Result := false;
end else begin
dotNetLocalPath := ExpandConstant('{src}') + '\'+dotNetName;
if not FileExists(dotNetLocalPath) then begin
dotNetLocalPath := ExpandConstant('{tmp}') + '\'+dotNetName;
if not FileExists(dotNetLocalPath) then begin
isxdl_AddFile(dotNetDownloadUrl, dotNetLocalPath);
dotNetDownloadNeeded := true;
end;
end; SetIniString('install', 'dotnetRedist', dotNetLocalPath, ExpandConstant('{tmp}\dep.ini'));
end; end;
//准备安装.net framework需要的条件(本地还是联网) 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) = 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) = 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 >= );
end; result := success and (install = ) and (serviceCount >= service);
end;
//检测是否存在(已安装)特定版本的.net framework //----------------------------------- //取得自定义的配置
// Setup.ini
// [Custom]
// dotNetVersion = v4.5
function GetCustomConfig(key:string):string;
var
myValue:string;
begin
myValue:=ExpandConstant('{ini:{src}\Setup.ini,Custom,'+key+'}')
result := myValue;
end; function InitializeSetup(): Boolean;
begin
//do something result:= true;
end;
//初始化安装 function IsIncludeFramework(version: string): boolean;
var
isInclued:boolean;
begin //最高版本的
if IsDotNetDetected('v4.5',) then begin
isInclued := true;
end else if version = 'v4.5' then begin
PreInstallDotNet('dotNetFx45_Full_setup.exe','http://download.microsoft.com/download/B/A/4/BA4A7E71-2906-4B2D-A0E1-80CF16844F5F/dotNetFx45_Full_setup.exe');
end else if IsDotNetDetected('v4\Full',) then begin
isInclued := true;
end else if version = 'v4\Full' then begin
PreInstallDotNet('dotNetFx40_Full_x86_x64.exe','http://download.microsoft.com/download/9/5/A/95A9616B-7A37-4AF6-BC36-D6EA96C8DAAE/dotNetFx40_Full_x86_x64.exe');
end else if IsDotNetDetected('v4\Client',) then begin
isInclued := true;
end else if version = 'v4\Client' then begin
PreInstallDotNet('dotNetFx40_Client_x86_x64.exe','http://download.microsoft.com/download/5/6/2/562A10F9-C9F4-4313-A044-9C94E0A8FAC8/dotNetFx40_Client_x86_x64.exe');
end else if IsDotNetDetected('v3.5',) then begin
isInclued := true;
end else if Pos('v3.5',version) = then begin
PreInstallDotNet('dotNetFx35setup.exe','http://download.microsoft.com/download/7/0/3/703455ee-a747-4cc8-bd3e-98a615c3aedb/dotNetFx35setup.exe');
end else if IsDotNetDetected('v3.0',) then begin
isInclued := true;
end else if Pos('v3.0',version) = then begin
PreInstallDotNet('dotNetFx35setup.exe','http://download.microsoft.com/download/7/0/3/703455ee-a747-4cc8-bd3e-98a615c3aedb/dotNetFx35setup.exe');
end else if IsDotNetDetected('v2.0.50727',) then begin
isInclued := true;
end else if Pos('v2',version) = then begin
PreInstallDotNet('dotnetfx.exe','http://download.microsoft.com/download/5/6/7/567758a3-759e-473e-bf8f-52154438565a/dotnetfx.exe');
end else if IsDotNetDetected('v1.1.4322',) then begin
isInclued:= true;
end else if Pos('v1',version)= then begin
PreInstallDotNet('dotNetFx35setup.exe','http://download.microsoft.com/download/7/0/3/703455ee-a747-4cc8-bd3e-98a615c3aedb/dotNetFx35setup.exe');
end; result := isInclued;
end; //检测是否安装了等于大于指定版本的.net framework
function NextButtonClick(CurPage: Integer): Boolean;
var
dotNetVersion:string;
begin
Result := true; if (CurPage = wpReady) then begin dotNetVersion := GetCustomConfig('dotNetVersion');
if Length(dotNetVersion) = then begin
dotNetVersion := 'v4.0';
end else if not (Pos('v',dotNetVersion) = ) then begin
dotNetVersion := 'v'+dotNetVersion;
end; if not IsIncludeFramework(dotNetVersion) then begin
if not DoInstallDotNet() then begin
MsgBox('当前操作需要安装.NET Framework ' + dotNetVersion + '或以上版本。'##
'在尝试自动安装期间,似乎出现一些小问题(或用户取消了安装),'#
'请重试尝试安装。', mbInformation, MB_OK);
result:= false;
end;
end; end; end;
//安装出错或取消时 procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
ErrorCode: Integer;
begin
case CurUninstallStep of
usUninstall:
begin
// 正在卸载
end;
usPostUninstall:
begin
//卸载完成
ShellExec('open', 'http://www.tdx-it.com', '', '', SW_SHOW, ewNoWait, ErrorCode) end;
end;
end; //软件卸载
Inno Setup 软件封装的更多相关文章
- [InnoSetup]Inno Setup软件打包脚本
脚本由 Inno Setup 脚本向导 生成! ; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档! #define MyAppName "SFT期货交易系统&quo ...
- 分享一个自用的 Inno Setup 软件打包脚本
此脚本支持打包mysql.安装mysql服务.安装windows服务.操作ini文件.操作注册表.高效压缩文件等功能,基本能满足常用的软件打包需求. ;定义各种常量 #define MyAppName ...
- inno setup 软件打包
2017-05-26 软件开发完毕以后,要进行打包发布,有几款打包用的软件很常见:innosetup,nullsoft,installshield.本人今天终于把自己独立开发的呈现软件打了包.第一个版 ...
- 使用Inno Setup 制作软件安装包详细教程(与开发语言无关)
前言:关于如何制作一个软件安装包的教程,与编程语言无关.以下,请看详情~ 1.下载Inno Setup,下载地址:https://jrsoftware.org/isinfo.php 2.下载最新版本即 ...
- Inno Setup 编译器
Inno Setup 编辑 Inno Setup用Delphi写成,其官方网站同时也提供源程序免费下载.它虽不能与Installshield这类恐龙级的安装制作软件相比,但也当之无愧算是后起之秀.In ...
- [Tool]Inno Setup创建软件安装程序。
这篇博客将介绍如何使用Inno Setup创建一个软件安装程序. Inno Setup官网:http://www.jrsoftware.org/isinfo.php. 可以下载到最新的Inno Set ...
- Inno setup 开源的安装包打包软件
Inno Setup是一个开源的安装包打包软件,下载地址是:http://www.jrsoftware.org/isdl.php 使用引导界面创建一个安装包打包 配置参考官方文档:http://www ...
- [Azure DevOps] 使用 Inno Setup 制作桌面软件安装包
1. 桌面应用程序的 CI/CD 桌面应用程序的 CI/CD 过程和网站有一些不同,毕竟桌面应用程序的"部署"只是将安装包分发到目标位置,连应用商店都不用上,根据公司的管理流程可以 ...
- 如何部署安装软件:vs2010 'VS' Inno Setup
一直以来就是调试程序,生成的文件在debug或者release下,当没有其他资源文件时,这些程序也不用打包,直接就能够运行,但是程序中总会有一些额外的资源文件,视频啊,图片啊.这些需要打包在一个安装文 ...
随机推荐
- 结巴分词中TFIDF的原理
之前了解TFIDF只是基于公式,今天被阿里面试官问住了,所以深入讨论下TFIDF在结巴分词中原理. 概念 TF-IDF(term frequency–inverse document frequenc ...
- 2018 Multi-University Training Contest 10 Solution
A - Problem A.Alkane 留坑. B - Problem B. Beads 留坑. C - Problem C. Calculate 留坑. D - Problem D. Permut ...
- hdu1199 线段树
这题说的是给了 n 个操作. 每个操作会把 [a,b] 之间的球 涂为黑色或者 白色, 然后最后问 最长的连续的白色的 球有多少个,初始的时候全是黑的. 我们将所有的点离散化, 记得离散 a-1, b ...
- C#——文件操作类简单封装
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.IO ...
- 用 Python 和 OpenCV 检测图片上的条形码(转载)
原文地址:http://python.jobbole.com/80448/ 假设我们要检测下图中的条形码: # load the image and convert it to grayscale 1 ...
- POJ - 1463 Strategic game (树状动态规划)
这题做的心塞... 整个思路非常清晰,d[i][0]表示第i个结点不设置监察的情况下至少需要的数量:d[i][1]表示第i个结点设置检查的情况下的最小需要的数量. 状态转移方程见代码. 但是万万没想到 ...
- System.DateTimeKind 的用法
最近在使用SQLite的数据库,发现SQLiteConnection类,有一个属性DateTimeKind 去msdn上找了下资料,http://msdn.microsoft.com/en-us/li ...
- 子网掩码与ip有实际关系吗?
子网掩码是作为ip地址的标识,还是本身就是ip地址的一部分?例如10.10.10.1/24和10.10.10.1/25是同一个ip地址吗? 作者:知乎用户链接:https://www.zhihu.co ...
- R语言包相关命令
R的包(package)通常有两种:1 binary package:这种包属于即得即用型(ready-to-use),但是依赖与平台,即Win和Linux平台下不同.2 Source package ...
- C++中的动态绑定
C++中基类和派生类遵循类型兼容原则:即可用派生类的对象去初始化基类的对象,可用派生类的对象去初始化基类的引用,可用派生类对象的地址去初始化基类对象指针. C++中动态绑定条件发生需要满足2个条件: ...