首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Inno安装程序:添加第二个自定义输入页面(第一个很好)

Inno安装程序:添加第二个自定义输入页面(第一个很好)
EN

Stack Overflow用户
提问于 2020-02-11 14:00:54
回答 1查看 307关注 0票数 0

在本论坛专家的帮助下,我使用此代码将自定义输入页添加到Inno安装脚本中:

代码语言:javascript
运行
复制
[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;

我现在试图添加第二个页面来请求第二个输入(另一个文件夹名)。我编写了以下代码,当我将其添加到现有代码(如上面所示)下面时,编译器不会抱怨,但是在运行脚本时,新页面不会出现。

显然,我遗漏了一些简单而明显的步骤,这将显示第二页,但这一步对我来说并不明显。如果有人能告诉我这个明显的步骤应该是什么,我将非常感激。我已经做了几个小时的实验,但没有成功。这是第二个代码块:

代码语言:javascript
运行
复制
[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.
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-02-11 14:26:36

我不知道您的代码是干什么的,因为您没有提供完整的示例。此代码适用于我,使用您的代码作为基础。对两个wpWelcome调用都使用CreateInputQueryPage也有效,但我的示例似乎更简洁。我使用的是InnoSetup 6.0.3(u)。

代码语言:javascript
运行
复制
; 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;
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60170591

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档