inno-setup - Inno Setup - 设置 [Files] 后使用 [Code] 中的输入作为参数
问题描述
我有一段脚本可以获取 Python Home 的位置。[代码]部分如下 -
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define code
#define MyAppName "API DAST"
#define MyAppVersion "0.1"
#define MyAppPublisher "Prateek Inc."
#define MyAppURL "https://prateek.com"
[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={{5547FBEE-AA97-4224-AF61-36C9F720270C}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\API_DAST
DisableDirPage=yes
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
OutputDir=mysetupcompiler
OutputBaseFilename=mysetup
Compression=lzma
SolidCompression=yes
WizardStyle=modern
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Files]
Source: "C:\Users\pnarendr\Desktop\API_DAST\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
; TODO: Change a few config files by running a Python Script. But first, get Python Home from input
Source: "C:\Users\pnarendr\Desktop\output.log"; DestDir: "{code:GetPythonHome}";
[Code]
var
OutputProgressWizardPage: TOutputProgressWizardPage;
OutputProgressWizardPageAfterID: Integer;
procedure InitializeWizard;
var
//InputQueryWizardPage: TInputQueryWizardPage;
//InputOptionWizardPage: TInputOptionWizardPage;
InputDirWizardPage: TInputDirWizardPage;
PrimaryServerPage: TInputQueryWizardPage;
InputFileWizardPage: TInputFileWizardPage;
OutputMsgWizardPage: TOutputMsgWizardPage;
OutputMsgMemoWizardPage: TOutputMsgMemoWizardPage;
AfterID: Integer;
PythonHome: String;
begin
//WizardForm.PasswordEdit.Text := '{#Password}';
AfterID := wpSelectTasks;
//AfterID := CreateCustomPage(AfterID, 'CreateCustomPage', 'ADescription').ID;
//InputQueryWizardPage := CreateInputQueryPage(AfterID, 'CreateInputQueryPage', 'ADescription', 'ASubCaption');
//InputQueryWizardPage.Add('&APrompt:', False);
//AfterID := InputQueryWizardPage.ID;
//InputOptionWizardPage := CreateInputOptionPage(AfterID, 'CreateInputOptionPage', 'ADescription', 'ASubCaption', False, False);
//InputOptionWizardPage.Add('&AOption');
//AfterID := InputOptionWizardPage.ID;
InputDirWizardPage := CreateInputDirPage(AfterID, 'Choose Python Home Folder', '', '', False, '');
InputDirWizardPage.Add('&Location of Python Home:');
InputDirWizardPage.Values[0] := 'C:\Python27'; //Default Value
AfterID := InputDirWizardPage.ID;
InputFileWizardPage := CreateInputFilePage(AfterID, 'CreateInputFilePage', 'ADescription', 'ASubCaption');
InputFileWizardPage.Add('&APrompt:', 'Executable files|*.exe|All files|*.*', '.exe');
//Will this get latest value even if you go back???
PythonHome := InputDirWizardPage.Values[0];
Log('Python Home - '+PythonHome);
AfterID := InputFileWizardPage.ID;
OutputMsgWizardPage := CreateOutputMsgPage(AfterID, 'CreateOutputMsgPage', 'ADescription', 'AMsg');
AfterID := OutputMsgWizardPage.ID;
OutputMsgMemoWizardPage := CreateOutputMsgMemoPage(AfterID, 'CreateOutputMsgMemoPage', 'ADescription', 'ASubCaption', 'AMsg');
AfterID := OutputMsgMemoWizardPage.ID;
OutputProgressWizardPage := CreateOutputProgressPage('CreateOutputProgressPage', 'ADescription');
OutputProgressWizardPageAfterID := AfterID;
end;
function NextButtonClick(CurPageID: Integer): Boolean;
var
Position, Max: Integer;
begin
if CurPageID = OutputProgressWizardPageAfterID then begin
try
Max := 25;
for Position := 0 to Max do begin
OutputProgressWizardPage.SetProgress(Position, Max);
if Position = 0 then
OutputProgressWizardPage.Show;
Sleep(2000 div Max);
end;
finally
OutputProgressWizardPage.Hide;
end;
end;
Result := True;
end;
function PrepareToInstall(var NeedsRestart: Boolean): String;
begin
if SuppressibleMsgBox('Do you want to stop Setup at the Preparing To Install wizard page?', mbConfirmation, MB_YESNO, IDNO) = IDYES then
Result := 'Stopped by user';
end;
function GetPythonHome(Param: String): string;
begin
Result := 'C:\Python27'; //Use default
end;
我不知道如何InputDirWizardPage.Values[0]
在设置后将其作为输入来运行 Python 脚本(更改复制文件夹中的配置文件)。我该怎么做 ?
处理了 Invalid Identifier 异常。显然 Pascal 脚本与 Pascal 不同
解决方案
推荐阅读
- android - 安卓| Java 通知未出现在 API 25 及更低版本中
- python - 如何使用 Tweepy 从用户的时间线实时获取推文
- xml - 如何在 YANG 中建模没有公共子元素的列表?
- git - .gitignore 文件不忽略 VS 文件
- python - 为python中数据框列表中的单个数据框赋值
- android - 如何在打开活动之前获取 api 结果(等待屏幕)
- pytorch - 无法使用两个 csv 输入文件为循环 gans 创建 Dataloader
- laravel - 如何与许多用户一起托管 Angular 前端和 Laravel 后端信使机器人
- rust - 有没有办法让一个特征为它扩展的另一个特征中的关联类型指定自己?
- apache - 带有 Docker 的 Apache Web 服务器和微服务