Windows软件打包发布教程
安装inno setup软件
,下载最新版本innosetup-6.2.2.exe
创建向导脚本
Create a new script file using Script Wizard
,然后点击
按照提示完成一步一步完成脚本参数配置,如下图①、② ...... ⑬ 、⑭
按快捷键(Ctrl + F9)或者点击工具栏从左到右第四个图标,编译脚本,生成exe安装包
最终生成exe文件,这个安装包会带有向导脚本里边填写的信息,如版本号、公司、文件说明等
有了脚本以后直接修改脚本就可以了(按需修改),不用每次都要填写向导脚本的流程,这里介绍脚本一些关键的变量和参数
宏定义
以下宏定义用于定义程序名、软件版本、发布者、发布者网站信息、关联的文件格式等
#define MyAppName "Example"
#define MyAppVersion "1.0.0"
#define MyAppPublisher "iotstuff"
#define MyAppURL "https://iotstuff.cn"
#define MyAppExeName "Example.exe"
#define MyAppAssocName MyAppName + " File"
#define MyAppAssocExt ".myp"
#define MyAppAssocKey StringChange(MyAppAssocName, " ", "") + MyAppAssocExt
Setup
setup用于定义一些基本的软件包信息
AppId={{75FF5697-7D83-46D7-824A-F4259ADE4FC3}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppName}
ChangesAssociations=yes
DisableProgramGroupPage=yes
OutputDir=E:\
OutputBaseFilename=Example
SetupIconFile=E:\logo.ico
Compression=lzma
SolidCompression=yes
WizardStyle=modern
Languages
setup程序的默认语言设置
Name: "english"; MessagesFile: "compiler:Default.isl"
Tasks
编译任务相关参数定义
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Files
输出的exe压缩包路径定义
Source: "E:\build\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:\build\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Registry
注册表相关信息,保存一些需要持久化的软件包信息
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}"; ValueType: string; ValueName: ""; ValueData: "{#MyAppAssocName}"; Flags: uninsdeletekey
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},0"
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1"""
Root: HKA; Subkey: "Software\Classes\Applications\{#MyAppExeName}\SupportedTypes"; ValueType: string; ValueName: ".myp"; ValueData: ""
Icons
程序logo自定义
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Run
可执行程序路径定义
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
阅读剩余
版权声明:
作者:hywing
链接:https://iotstuff.cn/windows-software-pack-tutorial/
文章版权归作者所有,未经允许请勿转载。
THE END