使用Inno Setup包含注册表,自定义消息和代码文件的正确方法

问题描述 投票:0回答:1

这听起来像是一个愚蠢的问题。目前,我已经创建了三个文件:

  1. AutoBackupSettingsPage
  2. AutoBackupSettingsPage_CustomMessages
  3. AutoBackupSettingsPage_Registry

第一个文件的顶部有一个[code]部分,由“自动备份”功能的处理程序和自定义页面提供。

第二个文件文件的顶部有[CustomMessages]节,后跟所有适当的自定义消息。

第三个文件在顶部具有[Registry]部分,后跟所有注册表项定义。

此刻,我正在使用#include这样的代码(代码被删除):

[registry]
#include ".\AutoBackupSettingsPage_Registry.iss"

[CustomMessages]
#include ".\AutoBackupSettingsPage_CustomMessages.iss"

[code]
program Setup;

// global variables
var
  bIsUpgrading: Boolean;
  dotnetRedistPath: string;
  dotNetNeeded: boolean;
  bDownloadHelpDocSetup: boolean;
  vcRedist64BitPath: string;
  vcRedist32BitPath: string;
  bVcRedist64BitNeeded : boolean;
  bVcRedist32BitNeeded : boolean;
  bSelectTasksVisited: Boolean;

{ Download Wizard Form plugin }
#define DwinsHs_Use_Predefined_Downloading_WizardPage
#define DwinsHs_Data_Buffer_Length 65536
#define DwinsHs_Auto_Continue
#include ".\dwinshs\dwinshs.iss"

{ Auto Backup Settings Page }
#include ".\AutoBackupSettingsPage.iss"

{ Import the LoadVCLStyle function from VclStylesInno.DLL }
procedure LoadVCLStyle(VClStyleFile: String); external 'LoadVCLStyleW@files:VclStylesInno.dll stdcall setuponly';
procedure LoadVCLStyle_UnInstall(VClStyleFile: String); external 'LoadVCLStyleW@{%TEMP}\VclStylesInno.dll stdcall uninstallonly delayload';

最初我想将所有文件放在一起,但后来我得出结论,在code开始之后插入registrycustom message部分是错误的。部分,这会混淆系统。因此,我通过使用不同的文件并在正确的部分中包含每个文件来简化事情。

这是使用Inno Setup做这种事情的正确方法吗?


为了清楚起见,这就是我的主ISS文件的上下文:

  • [setup]
  • [tasks]
  • [files]
  • [icons]
  • [run]
  • [uninstallrun]
  • [_istool]
  • [registry]
  • [uninstalldelete]
  • [installdelete]
  • [languages]
  • [custommessages]
  • [dirs]
  • [thirdparty]
  • [code]
  • [custommessages]
  • [registry]
  • [code]
  • [code]

带有#字符的将是单个#include文件。不知道是否破坏这样的code部分是否被认为是不好的设计?


为了论证,请取这些小块。它们只是传达了当您在#include部分的中间[code]拍打声时发生的情况的想法:

; Contents before here in master
; ...
; ...
[Code]
program Setup;

// global variables
var
  bIsUpgrading: Boolean;
  dotnetRedistPath: string;
  dotNetNeeded: boolean;
  bDownloadHelpDocSetup: boolean;
  vcRedist64BitPath: string;
  vcRedist32BitPath: string;
  bVcRedist64BitNeeded : boolean;
  bVcRedist32BitNeeded : boolean;
  bSelectTasksVisited: Boolean;

; =================================
; Start of included file

[Registry]
; 32 Bit
Root: "HKLM"; \
    Subkey: "Software\MeetSchedAssist\Meeting Schedule Assistant\Options"; \
    ValueType: dword; \
    ValueName: "BackupAtShutdownWhat"; \
    ValueData: "{code:GetWhatToBackupMode|0}"; \
    Flags: uninsdeletevalue; \
    Check: IsNewInstall

Root: "HKLM"; \
    Subkey: "Software\MeetSchedAssist\Meeting Schedule Assistant\Options"; \
    ValueType: dword; \
    ValueName: "BackupAtShutdownMode"; \
    ValueData: "{code:GetHowToBackupMode|0}"; \
    Flags: uninsdeletevalue; \
    Check: IsNewInstall

[CustomMessages]
pageAutoBackupTitle=Automatic Backup
pageAutoBackupDescription=Configure automatic backup settings.
lblBackupWhat=What to backup:
radBackupWhatNone=Don't perform any backup when the program shuts down
radBackupWhatComplete=Make a complete backup when the program shuts down
radBackupWhatEssential=Only make an essential backup when the program shuts down
lblBackupMode=How to backup:
radBackupModeAuto=Perform automatically when the program is shut down
radBackupModeManual=Prompt the user when the program is shut down
lblPromptMode=Also prompt to backup at the following intervals while the application is running:
cmbPromptModeItemNever=Never prompt to backup
cmbPromptModeItemDaily=Prompt to backup everyday
cmbPromptModeItemWeekly=Prompt to backup once a week
cmbPromptModeItemMonthly=Prompt to backup once a month
lblBackupFolder=Where to backup:


[code]

{ Constants }
const
  BackupWhat_None = 0;
  BackupWhat_Complete = 1;
  BackupWhat_Essential = 2;

    BackupMode_Automatic = 0;
  BackupMode_Manual = 1;

    BackupPrompt_Never = 0;
    BackupPrompt_Daily = 1;
    BackupPrompt_Weekly = 2;
    BackupPrompt_Monthly = 3;

{ Global Variables }
var
  pageAutoBackup: TWizardPage;
  pnlBackupWhat: TPanel;
  lblBackupWhat: TLabel;
  radBackupWhatNone: TNewRadioButton;
  radBackupWhatComplete: TNewRadioButton;
  radBackupWhatEssential: TNewRadioButton;
  lblBackupMode: TLabel;
  pnlBackupMode: TPanel;
  radBackupModeAuto: TNewRadioButton;
  radBackupModeManual: TNewRadioButton;
  lblPromptMode: TLabel;
  cmbPromptMode: TNewComboBox;
  lblBackupFolder: TLabel;
  txtBackupFolder: TNewEdit;
  btnSelectBackupFolder: TNewButton;

;====================================
; Now the master continues with the code:

{ Import the LoadVCLStyle function from VclStylesInno.DLL }
procedure LoadVCLStyle(VClStyleFile: String); external 'LoadVCLStyleW@files:VclStylesInno.dll stdcall setuponly';
procedure LoadVCLStyle_UnInstall(VClStyleFile: String); external 'LoadVCLStyleW@{%TEMP}\VclStylesInno.dll stdcall uninstallonly delayload';

{ Import the UnLoadVCLStyles function from VclStylesInno.DLL }
procedure UnLoadVCLStyles; external 'UnLoadVCLStyles@files:VclStylesInno.dll stdcall setuponly';
procedure UnLoadVCLStyles_UnInstall; external 'UnLoadVCLStyles@{app}\VclStylesInno.dll stdcall uninstallonly';

{ Importing ShowWindow Windows API from User32.DLL }
function ShowWindow(hWnd: Integer; uType: Integer): Integer; external '[email protected] stdcall';

const
  { Changed to 4.6.2 download link (see: http://msdn.microsoft.com/en-us/library/ee942965%28v=vs.110%29.aspx#redist) }
inno-setup
1个回答
0
投票

Inno Setup并不关心各部分的顺序。您甚至可以将这些部分拆分为多个部分,并以任意方式将其混合。

其余仅取决于您的编码风格和个人喜好。

© www.soinside.com 2019 - 2024. All rights reserved.