Это может показаться глупым вопросом. На данный момент я создал три файла:
AutoBackupSettingsPage
AutoBackupSettingsPage_CustomMessages
AutoBackupSettingsPage_Registry
Первый файл имеет раздел [Code]
вверху, за которым следуют обработчики и настраиваемая страница для моей функции автоматического резервного копирования c.
Второй файл файла имеет раздел [CustomMessages]
вверху, за которым следуют все соответствующие пользовательские сообщения.
В третьем файле есть раздел [Registry]
вверху, за которым следуют все определения ключей реестра.
В настоящий момент я использую #include
как это (код snipped):
[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';
Изначально я хотел объединить все файлы в один, но потом пришел к выводу, что вставлять разделы Registry
и CustomMessages
после начала Code
, и это запутает систему. Поэтому я упростил задачу, создав отдельные файлы и включив каждый в нужную секцию.
Это правильный способ делать такие вещи с 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 'ShowWindow@user32.dll stdcall';
const
{ Changed to 4.6.2 download link (see: http://msdn.microsoft.com/en-us/library/ee942965%28v=vs.110%29.aspx#redist) }