一个简单的inno setup模板
时间:2022-04-22
本文章向大家介绍一个简单的inno setup模板,主要内容包括一、模板代码、二、注意事项、基本概念、基础应用、原理机制和需要注意的事项等,并结合实例形式分析了其使用技巧,希望通过本文能帮助到大家理解应用这部分内容。
一、模板代码
基本功能包括多路径安装、多语言、自定义图标。
[Setup]
ShowLanguageDialog=yes
AppCopyright=Copyright Reserved(C) 2016, 360 Inc.
AppName={cm:Packagename}
AppVerName={cm:Packagename} {cm:Packagever}
LicenseFile=
OutputDir=C:/installer
UninstallFilesDir={code:getdlldir}/uninstall
ExtraDiskSpaceRequired=0
UserInfoPage=false
VersionInfoVersion=1.0
VersionInfoCompany=360 Inc.
VersionInfoDescription=360
EnableDirDoesntExistWarning=true
AppID={{007F4590-89DE-4F87-9608-10F07CEFBBE9}
LanguageDetectionMethod=uilanguage
UsePreviousSetupType=true
DisableStartupPrompt=true
DirExistsWarning=no
WizardImageFile=C:/Users/zzk/Desktop/FILES/PR512.bmp
WizardSmallImageFile=C:/Users/zzk/Desktop/FILES/PR64.bmp
SetupIconFile=C:/Users/zzk/Desktop/FILES/PR32.ico
ArchitecturesAllowed=x64 ia64
OutputBaseFilename=win64_setup
VersionInfoTextVersion=1.0
AppPublisher=360 Inc.
AppPublisherURL=http://www.360.com
AppVersion=1.0
AppContact=zhangzhongke007@163.com
UsePreviousTasks=false
UsePreviousAppDir=false
AllowRootDirectory=true
CreateAppDir=false
[Messages]
en.BeveledLabel=Created by 360 Inc.
chs.BeveledLabel=360荣誉出品
[Languages]
Name: "en"; MessagesFile: "compiler:Default.isl"; InfoBeforeFile: "readme-en.txt";
Name: "chs"; MessagesFile: "compiler:LanguagesChineseSimplified.isl"; InfoBeforeFile: "readme-cn.txt";
[Components]
Name: dllall; Description: {cm:installDllFile}; Types: full; Flags: disablenouninstallwarning
Name: prmall; Description: {cm:installPrmFile}; Types: full; Flags: disablenouninstallwarning; Languages:
[_ISTool]
OutputExeFilename=C:/install/win64_setup.exe
[Files]
Source: ./avcodec-56.dll; DestDir: {code:getdlldir}; Components: dllall
Source: ./avformat-56.dll; DestDir: {code:getdlldir}; Components: dllall
Source: ./avutil-54.dll; DestDir: {code:getdlldir}; Components: dllall
Source: ./custom.prm; DestDir: {code:getprmdir}; Components: prmall
[Dirs]
Name: {code:getdlldir}; Components: dllall
Name: {code:getprmdir}; Components: prmall
[CustomMessages]
Packagename=360 desktop
Packagever=1.0.0
en.installDllFile=install dynamic link files
chs.installDllFile=安装动态库
en.installPrmFile=install Premiere Pro CC plugin files
chs.installPrmFile=安装插件文件
en.choicedirCaption=Select Destination Location
chs.choicedirCaption=选择安装路径
en.choicedirDescription=Where should %1 be installed?
chs.choicedirDescription=你想将%1安装到哪里呢?
en.SelectDirLabel=Setup will install %1 into the following folder.
chs.SelectDirLabel=安装程序将%1安装到如下位置
en.choicedir=Choice for installation directory of %1
chs.choicedir=选择%1的安装位置
en.SelectDirBrowseLabel=To continue, click Next. If you would like to select a different folder, click Browse.
chs.SelectDirBrowseLabel=想要继续请点击"下一步"。如果需要切换安装目录,请点击"浏览"
en.Button1Browse=&Browse...
chs.Button1Browse=浏览(&B)
en.Button2Browse=B&rowse...
chs.Button2Browse=浏览(&R)
en.dlllabel=<The path to the system folders eg. C:/WINDOWS/System32>
chs.dlllabel=<系统目录如 C:/WINDOWS/System32>
en.prmlabel=<The plugin folder for Premiere Pro CC>
chs.prmlabel=<Premiere Pro CC公共插件目录>
en.installedDir=installation directory of %1
chs.installedDir=%1 的安装位置
[Code]
var
Dlldir: TLabel;
Prmdir: TLabel;
BitmapImage1: TBitmapImage;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
NewStaticText1: TNewStaticText;
NewStaticText2: TNewStaticText;
procedure ChoseDllFoldersClick(Sender: TObject);
var
choicedDIR:String;
begin
if BrowseForFolder(ExpandConstant('{cm:choicedir}'),choicedDIR,True) then
Edit1.Text := choicedDIR;
end;
procedure ChosePrmFoldersClick(Sender: TObject);
var
choicedDIR:String;
begin
if BrowseForFolder(ExpandConstant('{cm:choicedir}'),choicedDIR,True) then
Edit2.Text := choicedDIR;
end;
procedure choicedir_Activate(Page: TWizardPage);
begin
end;
function choicedir_ShouldSkipPage(Page: TWizardPage): Boolean;
begin
Result := False;
end;
function choicedir_BackButtonClick(Page: TWizardPage): Boolean;
begin
Result := True;
end;
function choicedir_NextButtonClick(Page: TWizardPage): Boolean;
begin
Result := True;
end;
procedure choicedir_CancelButtonClick(Page: TWizardPage; var Cancel, Confirm: Boolean);
begin
end;
function GetInstallString(): String;
var
sInstallPath: String;
begin
sInstallPath := 'C:Program FilesAdobeCommonPlug-ins7.0MediaCore';
if RegValueExists(HKLM64, 'SOFTWAREAdobePremiere ProCurrentVersion', 'Plug-InsDir') then
begin
RegQueryStringValue(HKLM64, 'SOFTWAREAdobePremiere ProCurrentVersion', 'Plug-InsDir', sInstallPath)
end
Result := sInstallPath;
end;
function choicedir_CreatePage(PreviousPageId: Integer): Integer;
var
Page: TWizardPage;
begin
Page := CreateCustomPage(
PreviousPageId,
ExpandConstant('{cm:choicedirCaption}'),
ExpandConstant('{cm:choicedirDescription,{cm:Packagename}}')
);
{ Dlldir }
Dlldir := TLabel.Create(Page);
with Dlldir do
begin
Parent := Page.Surface;
Left := ScaleX(0);
Top := ScaleY(88);
Width := ScaleX(24);
Height := ScaleY(16);
Caption := ExpandConstant('{cm:installedDir,DLL}') ;
Font.Color := -16777208;
Font.Height := ScaleY(-13);
Font.Name := 'Tahoma';
Font.Style := [fsBold];
end;
Prmdir := TLabel.Create(Page);
with Prmdir do
begin
Parent := Page.Surface;
Left := ScaleX(0);
Top := ScaleY(160);
Width := ScaleX(24);
Height := ScaleY(16);
Caption := ExpandConstant('{cm:installedDir,PRM}') ;
Font.Color := -16777208;
Font.Height := ScaleY(-13);
Font.Name := 'Tahoma';
Font.Style := [fsBold];
end;
{ BitmapImage1 }
BitmapImage1 := TBitmapImage.Create(Page);
with BitmapImage1 do
begin
Parent := Page.Surface;
Left := ScaleX(8);
Top := ScaleY(8);
Width := ScaleX(57);
Height := ScaleY(41);
end;
{ Label1 }
Label1 := TLabel.Create(Page);
with Label1 do
begin
Parent := Page.Surface;
Left := ScaleX(16);
Top := ScaleY(136);
Width := ScaleX(18);
Height := ScaleY(13);
Caption := ExpandConstant('{cm:dlllabel, DLLs}');
Color := -16777206;
Font.Color := 32768;
Font.Height := ScaleY(-12);
Font.Name := 'Tahoma';
end;
{ Label2 }
Label2 := TLabel.Create(Page);
with Label2 do
begin
Parent := Page.Surface;
Left := ScaleX(16);
Top := ScaleY(206);
Width := ScaleX(18);
Height := ScaleY(13);
Caption := ExpandConstant('{cm:prmlabel, PRMs}');
Font.Color := 32768;
Font.Height := ScaleY(-12);
Font.Name := 'Tahoma';
end;
{ Edit1 }
Edit1 := TEdit.Create(Page);
with Edit1 do
begin
Parent := Page.Surface;
Left := ScaleX(16);
Top := ScaleY(112);
Width := ScaleX(313);
Height := ScaleY(21);
TabOrder := 0;
Text := ExpandConstant('{sys}');
end;
{ Edit2 }
Edit2 := TEdit.Create(Page);
with Edit2 do
begin
Parent := Page.Surface;
Left := ScaleX(16);
Top := ScaleY(184);
Width := ScaleX(313);
Height := ScaleY(21);
TabOrder := 1;
Text := GetInstallString();
end;
{ Button1 }
Button1 := TButton.Create(Page);
with Button1 do
begin
Parent := Page.Surface;
Left := ScaleX(336);
Top := ScaleY(112);
Width := ScaleX(75);
Height := ScaleY(23);
Caption :=ExpandConstant('{cm:Button1Browse}');
TabOrder := 2;
OnClick := @ChoseDllFoldersClick;
end;
{ Button2 }
Button2 := TButton.Create(Page);
with Button2 do
begin
Parent := Page.Surface;
Left := ScaleX(336);
Top := ScaleY(184);
Width := ScaleX(75);
Height := ScaleY(23);
Caption := ExpandConstant('{cm:Button2Browse}');
TabOrder := 3;
OnClick := @ChosePrmFoldersClick;
end;
{ NewStaticText1 }
NewStaticText1 := TNewStaticText.Create(Page);
with NewStaticText1 do
begin
Parent := Page.Surface;
Left := ScaleX(16);
Top := ScaleY(16);
Width := ScaleX(22);
Height := ScaleY(17);
Caption := ExpandConstant('{cm:SelectDirLabel,Insta360 Plugin}');
Font.Color := -16777208;
Font.Height := ScaleY(-13);
TabOrder := 4;
end;
{ NewStaticText2 }
NewStaticText2 := TNewStaticText.Create(Page);
with NewStaticText2 do
begin
Parent := Page.Surface;
Left := ScaleX(16);
Top := ScaleY(50);
Width := ScaleX(22);
Height := ScaleY(17);
// Caption := 'µ¥»÷¡°ÏÂÒ»²½¡±¼ÌÐø¡£Èç¹ûÄãÏëÑ¡ÔñÆäËüÎļþ¼Ð£¬Çëµ¥»÷¡°ä¯ÀÀ¡±¡£';
Caption := ExpandConstant('{cm:SelectDirBrowseLabel,{cm:Packagename}}');
Font.Color := -16777208;
end;
with Page do
begin
OnActivate := @choicedir_Activate;
OnShouldSkipPage := @choicedir_ShouldSkipPage;
OnBackButtonClick := @choicedir_BackButtonClick;
OnNextButtonClick := @choicedir_NextButtonClick;
OnCancelButtonClick := @choicedir_CancelButtonClick;
end;
Result := Page.ID;
end;
function getdlldir(Param: String): String;
begin
Result := Edit1.Text;
end;
function getprmdir(Param: String): String;
begin
Result := Edit2.Text;
end;
procedure InitializeWizard();
begin
choicedir_CreatePage(wpUserInfo);
end;
二、注意事项
需要注意的是,[Languages]这一节中的文件路径,Default.isl和ChineseSimplified.isl文件都是放在inno setup的安装目录下,放在其他目录中是找不到的。Default.isl默认的是英文版本,如果需要其他语言的翻译也好办,在官网上有很多网友贡献了翻译过的文本,下载下来放到inno setup安装目录下的Languages目录下即可。
- 3433: [Usaco2014 Jan]Recording the Moolympics
- 3410: [Usaco2009 Dec]Selfish Grazing 自私的食草者
- 3391: [Usaco2004 Dec]Tree Cutting网络破坏
- 3404: [Usaco2009 Open]Cow Digit Game又见数字游戏
- GIF/PNG/JPG和WEBP/base64/apng图片优点和缺点整理
- 3400: [Usaco2009 Mar]Cow Frisbee Team 奶牛沙盘队
- 3409: [Usaco2009 Oct]Barn Echoes 牛棚回声
- 浅谈webp
- 3385: [Usaco2004 Nov]Lake Counting 数池塘
- 2761: [JLOI2011]不重复数字(平衡树)
- 无图片字体icon
- 数据结构(三):栈与队列
- 3555: [Ctsc2014]企鹅QQ
- 3381: [Usaco2004 Open]Cave Cows 2 洞穴里的牛之二
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- 进阶!MyBatis-Plus(基于 Springboot 演示)
- 运维人员常用的Linux命令总结
- Java反射机制的原理及在Android下的简单应用
- 温故而知新:MySQL存储引擎入门介绍
- 终于明白 Java 为什么要加 final 关键字了!
- 学习git这一篇就够了!!!
- 如何在nodejs中实现兄弟进程通信
- Python异常处理
- Python装饰器实现函数动态类型检查
- 如何自动填充SQL语句中的公共字段
- 面试官喜欢问的Java编译期与运行期问题总结全了
- 面试5年25K程序员回答不出来为什么Java的main方法必须是public static void?
- Python装饰器
- 3分钟短文:十年窖藏,Laravel告诉你表单验证的“正确姿势”
- 面试官:说说SpringBoot中Spring容器的启动过程