2013-10-10 23 views
14

Come posso passare una variabile dalla sezione [Code] ai parametri nella sezione [Run] in Inno Setup?Inno Setup: come passare la variabile da [Codice] a [Esegui]

Fondamentalmente, voglio fare quanto segue.

  1. Get e salvare l'input dell'utente a una variabile in una procedura InitializeWizard.
  2. Far passare l'input dell'utente ad un eseguibile in [Run] sezione

Ecco il mio codice.

[Run] 
Filename: "someProgram.exe"; Parameters: ??userInput?? 

[Code] 
procedure InitializeWizard; 
var 
    ConfigPage: TInputQueryWizardPage; 
    UserInput: String; 
begin 
    { Create the page } 
    ConfigPage := 
    CreateInputQueryPage(
     wpWelcome, 'User input', 'User input', 
     'Please specify the following information, then click Next.'); 

    { Add items (False means it's not a password edit) } 
    ConfigPage.Add('Input here:', False); 
    { Set initial values (optional) } 
    ConfigPage.Values[0] := ExpandConstant('hello'); 
    { Read values into variables } 
    UserInput := ConfigPage.Values[0]; 
end; 

Grazie.

risposta

20

Stai cercando il scripted constant. Vedere l'esempio seguente:

[Run] 
Filename: "SomeProgram.exe"; Parameters: {code:GetParams} 

[Code] 
var 
    ConfigPage: TInputQueryWizardPage; 

function GetParams(Value: string): string; 
begin 
    Result := ConfigPage.Values[0]; 
end; 

procedure InitializeWizard; 
begin 
    { Create the page } 
    ConfigPage := 
    CreateInputQueryPage(
     wpWelcome, 'User input', 'User input', 
     'Please specify the following information, then click Next.'); 
    { Add items (False means it's not a password edit) } 
    ConfigPage.Add('Input here:', False); 
    { Set initial values (optional) } 
    ConfigPage.Values[0] := ExpandConstant('hello'); 
end; 
+1

TLama, questo è esattamente quello che mi serviva. Ha funzionato. Grazie mille. – wcc

Problemi correlati