加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

重构 – 如何将Inno Setup脚本分成多个文件?

发布时间:2020-12-15 09:35:52 所属栏目:大数据 来源:网络整理
导读:我有两个共享公共代码的安装脚本.有可能重构它们吗? 一种方法是使用公共代码的文件,每个脚本都会引用该文件. 这可能吗? 解决方法 根据您使用的InnoSetup的版本,您可以使用包含文件.下面的示例使用三个文件(main.iss,code.iss,commonfiles.iss): 主文件:
我有两个共享公共代码的安装脚本.有可能重构它们吗?
一种方法是使用公共代码的文件,每个脚本都会引用该文件.
这可能吗?

解决方法

根据您使用的InnoSetup的版本,您可以使用包含文件.下面的示例使用三个文件(main.iss,code.iss,commonfiles.iss):

主文件:

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "My Program"
#define MyAppVerName "My Program 1.5"
#define MyAppPublisher "My Company,Inc."
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "MyProg.exe"

[Setup]
AppName={#MyAppName}
AppVerName={#MyAppVerName}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}{#MyAppName}
DefaultGroupName={#MyAppName}
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes

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

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "C:utilinnosetupExamplesMyProg.exe"; DestDir: "{app}"; Flags: ignoreversion

#include "CommonFiles.iss"

; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}{#MyAppName}"; Filename: "{app}{#MyAppExeName}"
Name: "{commondesktop}{#MyAppName}"; Filename: "{app}{#MyAppExeName}"; Tasks: desktopicon

[Run]
Filename: "{app}{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#MyAppName}}"; Flags: nowait postinstall skipifsilent

#include "code.iss"

CommonFiles.iss:

Source: "Common.DLL"; DestDir: "{app}"; Flags: ignoreversion

Code.iss:

[code]
function IsDotNET11Detected(): boolean;
// Indicates whether .NET Framework 1.1 is installed.
var
    success: boolean;
    install: cardinal;
begin
    success := RegQueryDWordValue(HKLM,'SOFTWAREMicrosoftNET Framework SetupNDPv1.1.4322','Install',install);
    Result := success and (install = 1);
end;

function InitializeSetup(): Boolean;
begin
    if not IsDotNET11Detected then begin
        MsgBox('This software requires the Microsoft .NET Framework 1.1.'#13#13
            'Please use Windows Update to install this version,'#13
            'and then re-run the setup program.',mbInformation,MB_OK);
        Result := false;
    end else
        begin
        MsgBox('Framework installed',MB_OK);
        Result := true;
        end
end;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读