Inno Setup打包工具例程

 

目录

一、前言

二、效果展示

三、教程&源码

四、Demo/相关包


 

一、前言

InnoSetup 是一个免费的 Windows 安装程序制作软件,简单的说,就是打包程序给用户安装。

 

二、效果展示

...

 

三、教程&源码

1. 打开编辑器,Inno Setup 5\Inno Setup 5\Compil32.exe

2. 编辑器->文件->打开,打开Inno Setup 5\setup.iss,可看到代码如下

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

#define MyAppName         "CTest1"
#define APP_FOLDER_NAME   "CTest1"
#define MyAppPublisher 	  "YJJ"
#define MyAppDate         "2020-04-21"
#define MyAppURL          "https://www.stu.edu.cn/"
#define MyAppExeName 	  "CTest1.exe"

#define VERSION_MAJOR       1
#define VERSION_MINOR       0
#define VERSION_SUBVRN      0
#define VERSION_REVISION    1
#define VERSION_SETUP       "setup"

[Setup]
; 注: AppId的值为单独标识该应用程序。
; 不要为其他安装程序使用相同的AppId值。
; (生成新的GUID,打开Inno Setup 5\Inno Setup 5\Compil32.exe 工具|在IDE中生成GUID。)
AppId={{7380C08E-B23A-4857-9423-F83C12415562}
;应用程序名称
AppName={#MyAppName}
;应用程序版本
AppVersion={#VERSION_MAJOR}.{#VERSION_MINOR}.{#VERSION_SUBVRN}.{#VERSION_REVISION}
;发布者信息
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#APP_FOLDER_NAME}
;创建开始菜单快捷方式文件夹名称
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
InfoBeforeFile=Readme.txt
;程序安装包输出路径
OutputDir=./
;安装和应用图标
SetupIconFile=./main.ico
WizardImageFile=./wizard.bmp
WizardSmallImageFile=./small.bmp
Compression=lzma
SolidCompression=yes
;程序安装包输出名称
OutputBaseFilename={#MyAppName}{#VERSION_MAJOR}.{#VERSION_MINOR}.{#VERSION_SUBVRN}.{#VERSION_REVISION}{#VERSION_SETUP}  
ShowUndisplayableLanguages = yes      
      
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "chinesesimp"; MessagesFile: "compiler:Languages\Chinesesimp.isl"
Name: "ChineseTrad"; MessagesFile: "compiler:Languages\ChineseTrad.isl"
Name: "french"; MessagesFile: "compiler:Languages\French.isl"
Name: "german"; MessagesFile: "compiler:Languages\German.isl"
Name: "italian"; MessagesFile: "compiler:Languages\Italian.isl"
Name: "japanese"; MessagesFile: "compiler:Languages\Japanese.isl"
Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"  
              
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkablealone;

[Files]
;制作安装包的主执行文件所在位置
Source: "..\CTest1\CTest1.exe"; DestDir:"{app}"; Flags:ignoreversion
;制作安装包的目录文件夹所在位置
Source: "..\CTest1\*"; DestDir: "{app}"; 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; WorkingDir: "{app}"

[Run]
;安装完毕后提示是否运行的项目名称
Filename: "{app}/{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

代码比较简单,可自行阅览。

如果需要改图标,还需自行替换文件main.ico,small.bmp,wizard.bmp,这里值得注意的是,请在网上使用工具转换为相关的文件,不能自行改后缀,否则格式不符合会报错。

例如本机是small.jpg文件,自行修改名称为small.bmp,编译后运行会找不到图片报错。

 

修改完毕后,点击菜单栏编译图标,即可在文件夹生成相关安装包

这就是打包后的安装包。

 

四、Demo/相关包

另附Inno Setup5软件和Demo供大家参考(百度云盘):

链接:https://pan.baidu.com/s/15qk40VjVoBJVSMa8pfZHfg 
提取码:89y9

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章