zoukankan      html  css  js  c++  java
  • Inno Setup的使用笔记

    项目需要,前些天学习了Inno Setup这跨打包工具的使用方法,收获蛮多的。由于之前也没有打包过,一时间学起来非常吃力。vs自带有打包的程序,但是自己也都从来没有用过,不知道强大不强大,反正目前就觉得Inno Setup挺不错的。听说什么酷狗啊,QQ啊,金山啊这种大牛都是用这个打包的。吃惊!

    界面美化这块没有做,如果以后有时间,可以再去看看,反正现在不想看了,也都挺郁闷的。

    这个是我放在D盘的东西,安装是生成安装包的的输入文件夹,lisense.txt是安装的协议说明,test2.iss就是inno setup的脚本文件了,后缀好像是Inno Setup Script的简写。x文件夹里面放的是数据,比如说可执行文件exe,数据库文件,各种dll,data文件夹里面放的是各种应用文件,net里面放了一个.net framework2.0和一个flash 10安装文件。

    ; 脚本由 Inno Setup 脚本向导 生成!
    ; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!


    #define MyAppName "q-lin"
    #define MyAppName2 "2005模块"
    #define MyAppName3 "0701办"
    #define MyAppVersion "2012"
    #define IncludeFramework true

    #define IncludeFlash true
    #define IsExternal ""
    #define MyAppPublisher "广州hoho"
    #define MyAppURL "http://www.hoho.com"
    #define MyAppExeName "Kao.exe"


    [Setup]
    ; 注: AppId的值为单独标识该应用程序。
    ; 不要为其他安装程序使用相同的AppId值。
    ; (生成新的GUID,点击 工具|在IDE中生成GUID。
    ;AppId值贮存于卸载日志文件 (unins???.dat) 内部
    AppId={{5154D16C-1E4E-417E-99B0-36669AF5048C}
    ;程序名
    AppName={#MyAppName}
    ;版本号
    AppVersion={#MyAppVersion}
    ;发布者
    AppPublisher={#MyAppPublisher}
    ;发布者链接
    AppPublisherURL={#MyAppURL}
    AppSupportURL={#MyAppURL}
    AppUpdatesURL={#MyAppURL}
    ;自述文件
    ;InfoAfterFile=D:\打包测试\info.txt
    ;安装协议
    LicenseFile=D:\打包测试\license.txt
    ;版权消息
    AppCopyright=Copyright (C) 2011-2012 My Company, Inc
    ShowComponentSizes=yes




    ;安装目录
    ;DefaultDirName={pf}\{#MyAppName2}
    DefaultDirName=d:\XX\{#MyAppName2}
    ;默认开始菜单栏
    DefaultGroupName={#MyAppName3}
    ;输出文件夹
    OutputDir=D:\打包测试\安装
    ;输出文件名
    OutputBaseFilename=setup
    ;安装的图标
    SetupIconFile=D:\打包测试\Setup.ico
    ;压缩相关 
    Compression=lzma
    SolidCompression=yes
    PrivilegesRequired=none




    ;背景图片(左边)
    WizardImageFile=f.bmp
    ;右上角图片
    ;WizardSmallImageFile=f.bmp  


    [Languages]
    Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"


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


    [Files]
    #if IncludeFlash
    Source: "D:\打包测试\x\net\flash10.exe"; DestDir: "{tmp}"; Flags: ignoreversion {#IsExternal};Check:NeedsFlash
    #endif

    //Flags: onlyifdoesntexist 文件存在的时才复制过去。
    Source: "D:\打包测试\x\*"; DestDir: "{app}"; Flags: ignoreversion {#IsExternal}
    Source: "D:\打包测试\x\data\*"; DestDir: "{app}\data"; Flags: ignoreversion {#IsExternal} 
    ;Source: "D:\打包测试\x\EasyKao.exe"; DestDir: "{app}"; Flags: sharedfile
    ;如果IncludeFramework为真则解压到安装目录(但事实上似乎没有用这个)
    #if IncludeFramework
    ;Check:NeedsFramework,检查这个函数,是否返回真,如果为真,则解压到安装目录
    Source: "D:\打包测试\x\net\dotnetfx.exe"; DestDir: "{tmp}"; Flags: ignoreversion {#IsExternal}; Check: NeedsFramework
    #endif
    ;注意: 不要在任何共享系统文件上使用“Flags: ignoreversion”,意为不比较版本信息


    [Icons]
    Name: "{group}\{#MyAppName2}"; Filename: "{app}\{#MyAppExeName}"
    Name: "{commondesktop}\{#MyAppName2}"; Filename: "{app}\{#MyAppExeName}"


    [Run]
    #if IncludeFlash
    Filename: {tmp}\flash10.exe;Parameters:"/install";WorkingDir: {tmp}; Flags: skipifdoesntexist; StatusMsg: "正在安装FLASH插件"
    #endif
    ;如果IncludeFramework为真则安装这个文件
    #if IncludeFramework
    ;静默安装参数Parameters: "/q:a /c:""install /l /q"""
    Filename: {tmp}\dotnetfx.exe; Parameters: "/q:a /c:""install /l /q"""; WorkingDir: {tmp}; Flags: skipifdoesntexist; StatusMsg: "正在安装.net 2.0组件,请稍侯"
    #endif
    Filename: "{app}\Kao.exe"; Description: "立即运行"; Flags: postinstall nowait skipifsilent unchecked 


    ;指定在卸载第一步要执行的程序数
    ;[UninstallRun]
    ;Filename: {win}\Microsoft.NET\Framework\v4.0.30319\CasPol.exe; Parameters: "-q -machine -remgroup ""{#MyAppName}"""; Flags: skipifdoesntexist runhidden;


    [code]


    //默认选择同意(安装的协议)
    procedure InitializeWizard();
    begin
    WizardForm.LICENSEACCEPTEDRADIO.Checked := true;
    end;


    // Indicates whether .NET Framework 2.0 is installed.
    function IsDotNET40Detected(): boolean;
    var
        success: boolean;
        install: DWord;
        begin
        success := RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client','Install',install)
        if success  and (install = 1)then
        begin
             Result := true;  
        end 
        ELSE 
                begin
                success := RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5', 'Install', install)
                if success  and (install = 1)then
                begin
                  Result := true;  
                end  
       else
               begin
               success := RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.0', 'Install', install)
               if success  and (install = 1)then
               begin
                   Result := true;  
               end   
           else
                 begin
                    success := RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v2.0.50727', 'Install', install)
                    if success  and (install = 1)then
                    begin
                      Result := true;  
                    end
          else
                 Result:=false;
                                
                                  end;       
                                  end;
                                  end;
                                  end;


    //检测是否需要安装.netframework
    function NeedsFramework(): Boolean;
    begin
      Result := (IsDotNET40Detected = false);
    end;   

    function IsFlashDetected(): boolean;
    var
        success2: boolean;
        install: DWord;
        begin
        success2 := RegValueExists(HKLM, 'SOFTWARE\Macromedia\FlashPlayer','CurrentVersion')
        if success2 then
        begin
        //MsgBox('你好。'+inttostr(install), mbInformation, MB_OK);
             Result := true;  
        end
        else
          // MsgBox('没有'+inttostr(install), mbInformation, MB_OK);
             Result := false; 
        end;


     
    //检测是否需要安装Flash Player
    function NeedsFlash(): Boolean;
    begin
      Result := (IsFlashDetected = false);
    end;  
     

    HKEY_LOCAL_MACHINE\SOFTWARE\Macromedia\FlashPlayer\SafeVersions在这里,如果安装了,则会有6.0、7.0……10.0、11.0

    在关于检测flash player这个问题上,有一些需要注意的地方。比如说, 安装10版本的时候必须把注册表里面的11和10都删除,否则不能安装。 11版本则可以重复安装本版本及以下版本。 

    为什么,我只检测是否有CurrentVersion而已,而不检测是否是10还是11,是因为似乎,只有10以上版本才出现在CurrentVersion这里。 好像10以下版本都是独立的player。

    注:我之前是没有做flash player检测的,而是每一次无论如何都安装一遍,如果有高版本的flash player的话,安装过程则会自动退出安装flash player这个过程。

    有的时候,inno setup程序在安装falsh的时候会产生错误,这个时候就会回滚,撤销flash所有接下来的执行。

    为什么会产生这种错误呢,有一种情况是这样的。比如说,我在安装flash player的时候会把安装的文件放在这个目录下,C:\WINDOWS\system32\Macromed\Flash,当我们卸载的时候,如果不是用该flash player的卸载程序就会卸载不干净,虽然注册表删得挺干净的,

    但是在这个目录下的文件有些就删不了,比如:Flash32_11_3_300_250.ocx。我们在安装的过程中,如果发现有此文件已经存在(假设我们安装的flash player是11.0版本),则显示安装错误。在不是静默安装的时候(手动安装)虽然结果显示安装错误,但还是可以用的,

    而静默安装则不是,只要有一点错误就会回滚。

  • 相关阅读:
    mysql 新用户添加和权限
    分治法
    插入排序
    猴子分桃问题
    关于PHP面向对象 静态方法的疑问
    php中static 静态变量和普通变量的区别
    php函数引用返回
    redis 限制请求次数的写法
    cas单点登录认证原理
    聚簇索引和非聚簇索引
  • 原文地址:https://www.cnblogs.com/hougelou/p/2854408.html
Copyright © 2011-2022 走看看