zoukankan      html  css  js  c++  java
  • 使用Innosetup制作安装包的一些技巧

    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;  
  • 相关阅读:
    http1.1长连接实战(一)
    【转】微服务与SOA之间差了一个ESB
    在SpringBoot 1.5.3上使用gradle引入hikariCP
    狮子心
    为啥他们不作为
    Redis 后台运行
    Jquery 动态生成的元素绑定事件
    linux tzselect 设置时区
    Docker 容器内配置Tomcat manager 远程控制
    Docker基于容器创建镜像
  • 原文地址:https://www.cnblogs.com/chenjian/p/5451853.html
Copyright © 2011-2022 走看看