使用Innosetup制作安装包的一些技巧

摘要:
%N单击[继续˃]按钮继续。

1. 选择安装界面上的图片

[plain] view plain copy
 
  1. [Setup]  
  2. ;设置界面上的两个图片  
  3. WizardImageFile=WizModernImage.bmp  
  4. WizardSmallImageFile=WizSmallImage.bmp  

2. 设置安装界面上的文字

[plain] view plain copy
 
  1. [Messages]  
  2. ;设置开始界面  
  3. WelcomeLabel1=%n欢迎安装 MyProgram开发系统   
  4. WelcomeLabel2=%n集MyProgram于一体的开发平台%n%n-单机版:用于开发MyProgram功能平台%n%n-网络版:用于开发MyProgram功能平台%n%n%n%n%n  
  5. ;设置许可证协议界面  
  6. WizardLicense=许可证协议  
  7. LicenseLabel=在安装“MyProgram开发系统”之前,请阅读%n授权协议  
  8. ;设置安装路径选择界面  
  9. WizardSelectDir=选择安装位置  
  10. SelectDirDesc=选择“MyProgram开发系统”的安装文件夹  
  11. SelectDirLabel3=-安装程序将安装 MyProgram开发系统 到下列文件夹%n%n-要安装到其他文件夹,单机[浏览(b)...]按钮并选择其他文件夹%n%n-点击[< 返回(B)]按钮返回上一个界面%n%n-选择[继续(N) >]按钮继续安装 MyProgram开发系统%n%n-选择[取消]按钮退出 MyProgram开发系统 安装  
  12. SelectDirBrowseLabel=  
  13. DiskSpaceMBLabel=  
  14. ;设置组件安装界面  
  15. WizardSelectComponents=选择组件  
  16. SelectComponentsDesc=选择您想要安装的 MyProgram开发系统 的组件  
  17. SelectComponentsLabel2=请选择您要安装的组件,清除您不想安装的组件。%n点击[继续(N) >]按钮继续。  
  18. ;设置准备安装界面  
  19. WizardReady=准备安装  
  20. ReadyLabel1=安装程序将安装 MyProgram开发系统  

3. 设置安装界面上的组件

[plain] view plain copy
 
  1. [Types]  
  2. ;设置组件的两种状态,完全安装与用户自定义安装  
  3. Name: "custom"; Description: "用户自定义安装"; Flags: iscustom  
  4. Name: "full"; Description: "完全安装"  
  5.   
  6. [Components]  
  7. ;默认为选择状态  
  8. Name: "demo1"; Description: "demo1"; Types: full custom; Flags: fixed;  
  9. ;默认为不选择状态,完全安装时为选择状态  
  10. Name: "demo2"; Description: "demo2"; Types: full;  
  11. ;默认为不选择状态  
  12. Name: "demo3"; Description: "demo3"; Types: full;  


 

4. 设置安装界面右上角图片大小及位置

[plain] view plain copy
 
  1. Var  
  2. PageName, PageDescription: TLabel;  


{设置安装界面右上角图片大小及位置}

[plain] view plain copy
 
  1. procedure InitializeWizard();  
  2. begin  
  3. {WizardForm.WizardSmallBitmapImage.width := 100;  
  4. WizardForm.WizardSmallBitmapImage.left := WizardForm.width - 100;  
  5. WizardForm.WizardSmallBitmapImage.height := 50;  
  6. WizardForm.PAGENAMELABEL.=100;  
  7. WizardForm.PAGEDESCRIPTIONLABEL.=200;}  
  8. PageName := TLabel.Create(WizardForm.MainPanel);  
  9. PageName.Parent := WizardForm.MainPanel;  
  10. PageName.Top := WizardForm.PageNameLabel.Top;  
  11. PageName.Left := WizardForm.PageNameLabel.Left;  
  12. PageName.Width := WizardForm.PageNameLabel.Width;  
  13. PageName.Height := WizardForm.PageNameLabel.Height;  
  14. PageName.Font := WizardForm.PageNameLabel.Font;  
  15. PageName.Transparent := true;  
  16. PageName.Font.Color:=clblack;  
  17.   
  18. PageDescription := TLabel.Create(WizardForm.MainPanel);  
  19. PageDescription.Parent := WizardForm.MainPanel;  
  20. PageDescription.Top := WizardForm.PageDescriptionLabel.Top;  
  21. PageDescription.Left := WizardForm.PageDescriptionLabel.Left;  
  22. PageDescription.Width := WizardForm.PageDescriptionLabel.Width;  
  23. PageDescription.Height := WizardForm.PageDescriptionLabel.Height;  
  24. PageDescription.Font := WizardForm.PageDescriptionLabel.Font;  
  25. PageDescription.Transparent := true;  
  26. PageDescription.Font.Color:=clblack;  
  27.   
  28. WizardForm.WizardSmallBitmapImage.Top := ScaleY(0);  
  29. WizardForm.WizardSmallBitmapImage.Left := ScaleX(0);  
  30. WizardForm.WizardSmallBitmapImage.Width := WizardForm.MainPanel.Width;  
  31. WizardForm.WizardSmallBitmapImage.Height := WizardForm.MainPanel.Height;  
  32. WizardForm.PageNameLabel.Visible := false;  
  33. WizardForm.PageDescriptionLabel.Visible := false;  
  34. end;  
  35.   
  36. procedure CurPageChanged(CurPageID: Integer);  
  37. begin  
  38. PageName.Caption := WizardForm.PageNameLabel.Caption;  
  39. PageDescription.Caption := WizardForm.PageDescriptionLabel.Caption;  
  40. PageDescription.=300;  
  41. end;  

5. 定义[Message]段颜色

[plain] view plain copy
 
  1. procedure InitializeWizard();  
  2. begin  
  3. WizardForm.BeveledLabel.Enabled:= True;  
  4. WizardForm.BeveledLabel.Font.Color:= clblue;  
  5.   
  6. end;  

6. 安装、卸载时判断是否程序正在运行,卸载完成时自动打开网页

[plain] view plain copy
 
  1. var  
  2. ErrorCode: Integer;  
  3. IsRunning: Integer;  
  4. // 安装时判断客户端是否正在运行    
  5. function InitializeSetup(): Boolean;    
  6. begin    
  7. Result :=true; //安装程序继续    
  8. IsRunning:=FindWindowByWindowName('东方宽频网络电视');    
  9. while IsRunning0 do    
  10. begin    
  11.     if Msgbox('安装程序检测到客户端正在运行。' #13#13 '您必须先关闭它然后单击“是”继续安装,或按“否”退出!', mbConfirmation, MB_YESNO) = idNOthen    
  12.     begin    
  13.       Result :=false; //安装程序退出    
  14.       IsRunning :=0;    
  15.     end else begin    
  16.       Result :=true; //安装程序继续    
  17.       IsRunning:=FindWindowByWindowName('东方宽频网络电视');    
  18.     end;    
  19. end;    
  20. end;    
  21. // 卸载时判断客户端是否正在运行    
  22. function InitializeUninstall(): Boolean;    
  23. begin    
  24.    Result :=true; //安装程序继续    
  25. IsRunning:=FindWindowByWindowName('东方宽频网络电视');    
  26. while IsRunning0 do    
  27. begin    
  28.     
  29.     if Msgbox('安装程序检测到客户端正在运行。' #13#13 '您必须先关闭它然后单击“是”继续安装,或按“否”退出!', mbConfirmation, MB_YESNO) = idNOthen    
  30.     begin    
  31.       Result :=false; //安装程序退出    
  32.       IsRunning :=0;    
  33.     end else begin    
  34.       Result :=true; //安装程序继续    
  35.       IsRunning:=FindWindowByWindowName('东方宽频网络电视');      
  36.     end;    
  37. end;    
  38. end;    
  39. procedure CurUninstallStepChanged(CurUninstallStep:TUninstallStep);    
  40. begin    
  41. case CurUninstallStep of    
  42.     usUninstall:      
  43.       begin // 开始卸载    
  44.       end;    
  45.     usPostUninstall:    
  46.       begin      //卸载完成    
  47.         // MsgBox('CurUninstallStepChanged:'#13#13 'Uninstall just finished.', mbInformation, MB_OK);    
  48.         // ...insert code to performpost-uninstall tasks here...    
  49.         ShellExec('open','http://www.dreams8.com', '', '', SW_SHOWNORMAL, ewNoWait,ErrorCode);    
  50.       end;    
  51. end;    
  52. end;   

7. 去掉安装程序左上角“关于安装程序”的代码

[plain] view plain copy
 
  1. procedureInitializeWizard();  
  2. begin  
  3. WizardForm.BorderIcons:= [biMinimize];  
  4. end;  
  5. procedure CurPageChanged(CurPage: Integer);  
  6. begin  
  7. if CurPage=wpWelcome then  
  8. WizardForm.BorderIcons:= [biSystemMenu, biMinimize];  
  9. end;  
  10. 或者  
  11. procedure InitializeWizard();  
  12. begin  
  13. WizardForm.BORDERICONS := [biHelp, biSystemMenu, biMinimize];  
  14. end;   

8. 添加“关于”和网站链接按钮

[plain] view plain copy
 
  1. procedure URLLabelOnClick(Sender: TObject);  
  2. var  
  3. ErrorCode: Integer;  
  4. begin  
  5. ShellExec('open', 'http://www.vistaqq.com', '', '', SW_SHOWNORMAL, ewNoWait,ErrorCode);  
  6. end;  
  7. procedure AboutButtonOnClick(Sender: TObject);  
  8. begin  
  9. MsgBox(#13 'Vista 状态条风格盘符' #13 #13'本软件由jinn制作,希望各位登陆中天VIP工作室!' #13#13 '版权所有 (C) 中天VIP工作室', mbInformation, MB_OK);  
  10. end;  
  11. var  
  12.     AboutButton, CancelButton: TButton;  
  13.     URLLabel: TNewStaticText;  
  14. procedure InitializeWizard();  
  15. begin  
  16. { Create the pages }  
  17. WizardForm.PAGENAMELABEL.Font.Color:= clred;  
  18. WizardForm.PAGEDESCRIPTIONLABEL.Font.Color:= clBlue;  
  19. WizardForm.WELCOMELABEL1.Font.Color:= clGreen;  
  20. WizardForm.WELCOMELABEL2.Font.Color:= clblack;  
  21.    CancelButton := WizardForm.CancelButton;  
  22.      AboutButton := TButton.Create(WizardForm);  
  23.      AboutButton.Left := WizardForm.ClientWidth -CancelButton.Left - CancelButton.Width;  
  24.      AboutButton.Top := CancelButton.Top;  
  25.      AboutButton.Width := CancelButton.Width;  
  26.      AboutButton.Height := CancelButton.Height;  
  27.      AboutButton.Caption := '&About';  
  28.      AboutButton.OnClick := @AboutButtonOnClick;  
  29.      AboutButton.Parent := WizardForm;  
  30. URLLabel := TNewStaticText.Create(WizardForm);  
  31.     URLLabel.Caption := '中天VIP工作室';  
  32.     URLLabel.Cursor := crHand;  
  33.     URLLabel.OnClick := @URLLabelOnClick;  
  34.     URLLabel.Parent := WizardForm;  
  35.     { Alter Font *after* setting Parent so the correctdefaults are inherited first }  
  36.     URLLabel.Font.Style := URLLabel.Font.Style +[fsUnderline];  
  37.     URLLabel.Font.Color := clBlue;  
  38.     URLLabel.Top := AboutButton.Top + AboutButton.Height -URLLabel.Height - 2;  
  39.     URLLabel.Left := AboutButton.Left + AboutButton.Width +ScaleX(20);  
  40. end;  

9. 安装时播放音乐

在脚本编译里的[Code]与[Files]段处添加以下代码:

[plain] view plain copy
 
  1. Function mciSendString(lpszCommand: String; lpszReturnString: Integer;cchReturnLength: Integer; hwndCallback: Integer): Integer;  
  2. external 'mciSendStringA@winmm.dll stdcall';  
  3.   
  4.   
  5. procedure InitializeWizard();  
  6. var  
  7.    BGMusicFile, SplashFile: string;  
  8. SplashForm: TForm;  
  9. SplashFileName: String;  
  10. I: Integer;   
  11. begin  
  12.   
  13. ExtractTemporaryFile(ExtractFileName(ExpandConstant('{tmp}music.mp3')));  
  14. SplashForm := TForm.create(nil);  
  15. with SplashForm do  
  16.    begin  
  17. mciSendString(ExpandConstant('play {tmp}music.mp3'),0,0,0);  
  18. Close;  
  19. Free;  
  20.    end;  
  21. end;  
  22.   
  23. [Files]  
  24. Source: "C:music.mp3"; Flags: dontcopy  

或者

[plain] view plain copy
 
  1. Source: "C:mymusic.mp3";DestDir: "{tmp}"; Flags: dontcopy  

代码说明:[Code]中蓝色代码{tmp}与music.mp3的意思是播放inno setup安装时创建的临时文件夹内的music.mp3音乐文件!

[Files]中C:music.mp3是你音乐源文件的地址,填自己的音频名称与音频格式。Flags: dontcopy 的意思是在安装时将音乐文件放到Inno Setup所创建的临时文件夹内,并且在完成安装后删除此音乐文件

10. 关于Inno Setup安装欢迎界面文字与安装向导文字颜色修改

[plain] view plain copy
 
    1. procedure InitializeWizard();  
    2.   
    3. begin  
    4.   
    5. //改变欢迎页面文字的颜色 (如图)  
    6.   
    7. WizardForm.WelcomeLabel1.Font.Color:= clNavy;  
    8.   
    9. WizardForm.WelcomeLabel2.Font.Color:= clTeal;  
    10.   
    11. end;  

免责声明:文章转载自《使用Innosetup制作安装包的一些技巧》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇[WPF](小结4)TreeView的数据分层模板ant design vue级联选择懒加载省市区三级数据下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

随便看看

IntelliJ IDEA(2017)安装和破解

IDEA全称IntelliJIDEA,是Java语言开发的集成环境,IntelliJ在业界被公认为最好的java开发工具之一,尤其在智能代码助手、代码自动提示、重构、J2EE支持、各类版本工具、JUnit、CVS整合、代码分析、创新的GUI设计等方面的功能可以说是超常的。用记事本打开分别在最下面一行增加一行:-javaagent:D:IDEAinJetbra...

ubuntu的ufw如何开放特定端口?

ubuntu的ufw是如何打开特定端口的?1.安装sudoapt getinstallufw2.启用sudoufwenable以默认情况下禁用外部访问sudoufwdefaultdeny 3.查看状态sudoufwstatus4.添加端口sudoufwallow80805。删除端口sudoufwdeleteallow808080806。允许特定源的IP地址从...

backgroundsize

当背景大小值为和时,可以设置两个值,也可以设置一个值。当只取一个值时,第二个值相当于auto,但此处的auto不会将背景图像的高度保持在其原始高度,而是与第一个值相同。此外,如果只取一个值,宽度和高度将相同,这相当于背景大小:80%自动。...

安装pygame

在python3中安装pygame库。一段时间后,您可以看到安装成功,并且可以导入pygame...

在oracle里,如何取得本周、本月、本季度、本年度的第一天和最后一天的时间

在Oracle中,如何获取本周、本月、本季度和今年的第一天和最后一天的时间------解决方案-------本周从dual中选择trunk+1;从dual中选择trunk+7;--选择本月的双截;从dual中选择last_ days;--本季精选双截;从dual中选择add_ months-1;--今年从dual中选择trunk;selectadd_ mon...

《转》Visual Studio 2015的安装与基本使用(社区版)

最重要的社区版本是免费的!因此,您不需要使用破解的旧VC++6.0、CometoVS2015和joyit,这与现代系统不兼容!获取Visual Studio 2015,进入Visual Studio官方网站,点击“下载Visual Studio社区”。“启动Visual Studio”稍等片刻,您将看到以下界面:单击菜单:“文件”-“新建”-“项目”,将出现...