Inno Setup脚本示例,Inno Setup例子,Inno Setup Demo

原创作品,未经允许请勿转载; http://blog.csdn.net/mynameislinduan


Inno Setup代码,Inno Setup安装脚本,Inno setup demo, Inno Setup示例,Inno Setup例子

1.简单介绍

在制作Windows应用程序的过整,需要做一个建议安装包,用到Inno Setup这个工具,此工具开源,使用脚本即可编译,脚本可以使用pascal语言做。下面举例一个建议的安装脚本例子,基本符合一般用户的使用。

2. Inno Setup 5.5 + 安装脚本

  • 此脚本在Inno setup 5.5以上版本试验成功,可正确编译运行。

Inno Setup 脚本,里面包含了Pascal代码。


;定义程序名字,定义程序版本,定义可执行文件的名字,定义父母目录等等

#define MyAppName "XX_XX"
#define MyAppVersion "1.0.0" 

#define MyAppExeName "XX_Ctrl.exe"
#define ParentDir ".."

[Setup]
; 注: AppId的值为单独标识该应用程序。
; 不要为其他安装程序使用相同的AppId值。
; (生成新的GUID,点击 工具|在IDE中生成GUID。)
;注意,下面的id要每个版本都不一样,以anysan36的版本为基础,改变最后的数字,例如现在的最后字符30表示30版本,add by done
WindowVisible=yes
AppId={{76754C92-F70C-46D4-A595-2C298E552B30}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
;AppPublisher={#MyAppPublisher}
;AppPublisherURL={#MyAppURL}
;AppSupportURL={#MyAppURL}
;AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
OutputDir={#ParentDir}\setup
OutputBaseFilename={#MyAppName}_{#MyAppVersion}_setup
SetupIconFile={#ParentDir}\MyExeDir\res\MyExeDir.ico
Compression=lzma
SolidCompression=yes
WizardSmallImageFile="up.bmp"
;上边框图


;添加许可文件 
LicenseFile=xkfile.txt

;右上角图片背景颜色  
WizardSmallImageBackColor=clGray  
;右边图片背景颜色  
WizardImageBackColor=clGray 
;左边图片是否拉伸 - yes;no  
WizardImageStretch=no  


;小图标,左边小图标
WizardImageFile="left.bmp"
;向导里面的图片,导向背景图片;
[Languages]
;add by done,中英文双语安装
;Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"
Name: "Chinese"; MessagesFile: "compiler:Languages\Chinese.isl"
Name: "english"; MessagesFile: "compiler:Default.isl"


[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkablealone
; OnlyBelowVersion: 0,6.1
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkablealone

[Files]
Source: "{#ParentDir}\MyExeDir\Release\MyExeDir.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#ParentDir}\UTL_10_B_USB.dl\Release\UTL_10_B_USB.dll"; DestDir: "{app}"; Flags: ignoreversion
;Source: "{#ParentDir}\UTL_10_B_USB.dl\Release\UTL_10_B_USB.lib"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#ParentDir}\UTL_10_B_USB_Senior\Release\UTL_10_B_USB_Senior.dll"; DestDir: "{app}"; Flags: ignoreversion
;Source: "{#ParentDir}\UTL_10_B_USB_Senior\Release\UTL_10_B_USB_Senior.lib"; DestDir: "{app}"; Flags: ignoreversion
;Source: "E:\DirPath\MyExeDir\Release\bulkusb.inf"; DestDir: "{app}"; Flags: ignoreversion
;Source: "E:\DirPath\MyExeDir\Release\BULKUSB.sys"; DestDir: "{app}"; Flags: ignoreversion
; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion”

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon

[Code]
procedure InheritBoundsRect(ASource, ATarget: TControl);
begin
  ATarget.Left := ASource.Left;
  ATarget.Top := ASource.Top;
  ATarget.Width := ASource.Width;
  ATarget.Height := ASource.Height;
end;

procedure InitializeWizard;
var
  PageName, PageDescription: TLabel;
  BottomWelcomeLabel: TLabel;
  BackgroundImage: TBitmapImage;

begin 
//启动安装许可协议
  WizardForm.LICENSEACCEPTEDRADIO.Checked:=true;  

  //WizardForm.DiskSpaceLabel.Visible := False;//安装说明,安装路径选择说明
  //WizardForm.SelectDirBrowseLabel.Visible := False;
  //WizardForm.SelectDirLabel.Visible := False;

  BackgroundImage := TBitmapImage.Create(MainForm);
  BackgroundImage.Parent := MainForm;
  BackgroundImage.SetBounds(0, 0, MainForm.ClientWidth, MainForm.ClientHeight);
  BackgroundImage.Stretch := True;
  //ExtractTemporaryFile('D:\Image2.bmp');
  //解压背景图到临时文件夹,让安装程序使用
  BackgroundImage.Bitmap.LoadFromFile(ExpandConstant('.\back.bmp'));


  WizardForm.WizardBitmapImage.Align := alLeft;
  WizardForm.WizardSmallBitmapImage.Align := alRight;
  //WizardForm.WizardBitmapImage.Bitmap.LoadFromFile('D:\Image.bmp');


  //TopWelcomeLabel := TLabel.Create(WizardForm);
  //TopWelcomeLabel.Parent := WizardForm.WelcomeLabel1.Parent;
  //TopWelcomeLabel.Font := WizardForm.WelcomeLabel1.Font;
  //TopWelcomeLabel.Caption := WizardForm.WelcomeLabel1.Caption;
  //TopWelcomeLabel.WordWrap := WizardForm.WelcomeLabel1.WordWrap;
  //TopWelcomeLabel.Transparent := True;
  //InheritBoundsRect(WizardForm.WelcomeLabel1, TopWelcomeLabel);
  //WizardForm.WelcomeLabel1.Visible := False;

  //BottomWelcomeLabel := TLabel.Create(WizardForm);
  //BottomWelcomeLabel.Parent := WizardForm.WelcomeLabel2.Parent;
  //BottomWelcomeLabel.Font := WizardForm.WelcomeLabel2.Font;
  //BottomWelcomeLabel.Caption := WizardForm.WelcomeLabel2.Caption;
  //BottomWelcomeLabel.WordWrap := WizardForm.WelcomeLabel2.WordWrap;
  //InheritBoundsRect(WizardForm.WelcomeLabel2, BottomWelcomeLabel);
  //WizardForm.WelcomeLabel2.Visible := True;

  PageName := TLabel.Create(WizardForm.MainPanel); 
  PageName.Parent := WizardForm.MainPanel; 
  PageName.Top := WizardForm.PageNameLabel.Top; 
  PageName.Left := WizardForm.PageNameLabel.Left; 
  PageName.Width := WizardForm.PageNameLabel.Width; 
  PageName.Height := WizardForm.PageNameLabel.Height; 
  PageName.Font := WizardForm.PageNameLabel.Font; 
  PageName.Transparent := true; 
  //PageName.Caption :='测试,测试,测试,测试,测试,测试,测试,测试,测试,测试,测试,'; 
  PageName.Font.Color:=clRed; 

  PageDescription := TLabel.Create(WizardForm.MainPanel); 
  PageDescription.Parent := WizardForm.MainPanel; 
  PageDescription.Top := WizardForm.PageDescriptionLabel.Top; 
  PageDescription.Left := WizardForm.PageDescriptionLabel.Left; 
  PageDescription.Width := WizardForm.PageDescriptionLabel.Width; 
  PageDescription.Height := WizardForm.PageDescriptionLabel.Height; 
  PageDescription.Font := WizardForm.PageDescriptionLabel.Font; 
  PageDescription.Transparent := true; 

  PageDescription.Font.Color:=clPurple; 

end;



[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

[UninstallDelete] 
Type: filesandordirs; Name: "{app}"

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

mynameislinduan

你的鼓励是我最大动力写博客不易

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值