在此论坛的专家帮助下,我使用以下代码将自定义输入页面添加到Inno Setup脚本中:
[Code]
var
UserInputsPage: TInputQueryWizardPage;
function GetWatchFolder(Param: string): string;
begin
Result := UserInputsPage.Values[0];
end;
[Code]
procedure InitializeWizard;
var
dfPath: string;
begin
dfPath := 'C:\TEMP';
RegQueryStringValue(HKCU, 'SOFTWARE\WPDOS.org', 'FilePrintPath', dfPath );
{ Create the page }
UserInputsPage :=
CreateInputQueryPage(wpWelcome,
'Folder to watch', 'Enter the path to the folder that you want me to watch. I will create it if it does not exist.',
'Please type a folder path, then click Next.');
UserInputsPage.Add('Folder to watch:', False);
UserInputsPage.Values[0] := dfPath;
end;
我现在正尝试添加第二个页面,以请求第二个输入(另一个文件夹名称)。我编写了以下代码,并将其添加到现有代码(如上所示)下面时,编译器不会抱怨,但是运行脚本时不会出现新页面。
很明显,我省去了一些简单而明显的步骤来显示第二页,但是这一步对我来说并不明显。如果有人可以告诉我那明显的步骤应该是什么,我将不胜感激。我已经尝试了几个小时而没有成功。这是第二段代码:
[Code]
var
UserInputsPage2: TInputQueryWizardPage;
function GetPdfPathFolder(Param: string): string;
begin
Result := UserInputsPage2.Values[0];
end;
[Code]
var
pdfPath: string;
begin
pdfPath := '';
RegQueryStringValue(HKCU, 'SOFTWARE\WPDOS.org', 'pdfPath', pdfPath );
{ Create the page }
UserInputsPage2 :=
CreateInputQueryPage(wpWelcome,
'Folder for saved PDFs', 'By default I will save PDFs to the desktop. If you want to us a different folder, enter its path here. I will create it if it does not exist.',
'Please type a folder path, then click Next.');
UserInputsPage2.Add('Folder for saved PDFs (leave blank to use desktop):', False);
UserInputsPage2.Values[0] := pdfPath;
end.
答案 0 :(得分:1)
我不知道您的代码做什么,因为您没有提供完整的示例。该代码以您的代码为基础对我有用。对于两个wpWelcome
调用都使用CreateInputQueryPage
也是可行的,但我的示例似乎更简洁。我正在使用InnoSetup 6.0.3(u)。
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "My Program"
#define MyAppVersion "1.5"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "MyProg.exe"
[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{380D65F4-34C6-4E55-B806-1EE46EEBD2B6}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppName}
DisableProgramGroupPage=yes
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
OutputBaseFilename=mysetup
Compression=lzma
SolidCompression=yes
WizardStyle=modern
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "C:\Program Files (x86)\Inno Setup 6\Examples\MyProg.exe"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
[Code]
var
UserInputsPage: TInputQueryWizardPage;
UserInputsPage2: TInputQueryWizardPage;
pdfPath: string;
function GetPdfPathFolder(Param: string): string;
begin
Result := UserInputsPage2.Values[0];
end;
function GetWatchFolder(Param: string): string;
begin
Result := UserInputsPage.Values[0];
end;
[Code]
procedure InitializeWizard;
var
dfPath: string;
begin
dfPath := 'C:\TEMP';
RegQueryStringValue(HKCU, 'SOFTWARE\WPDOS.org', 'FilePrintPath', dfPath );
{ Create the page }
UserInputsPage :=
CreateInputQueryPage(wpWelcome,
'Folder to watch', 'Enter the path to the folder that you want me to watch. I will create it if it does not exist.',
'Please type a folder path, then click Next.');
UserInputsPage.Add('Folder to watch:', False);
UserInputsPage.Values[0] := dfPath;
pdfPath := '';
RegQueryStringValue(HKCU, 'SOFTWARE\WPDOS.org', 'pdfPath', pdfPath );
{ Create the page }
UserInputsPage2 :=
CreateInputQueryPage(UserInputsPage.ID,
'Folder for saved PDFs', 'By default I will save PDFs to the desktop. If you want to us a different folder, enter its path here. I will create it if it does not exist.',
'Please type a folder path, then click Next.');
UserInputsPage2.Add('Folder for saved PDFs (leave blank to use desktop):', False);
UserInputsPage2.Values[0] := pdfPath;
end;