我有一段脚本来获取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并不相同