2013-10-10 13 views
14

Làm cách nào để chuyển biến từ mục [Code] đến tham số trong mục [Run] trong Thiết lập Inno?Cài đặt Inno: Cách chuyển biến từ [Mã] sang [Chạy]

Về cơ bản, tôi muốn làm như sau.

  1. Nhận và lưu đầu vào của người dùng vào biến trong quy trình InitializeWizard.
  2. Vượt qua đầu vào người sử dụng khả năng thực hiện trong [Run] phần

Đây là mã của tôi.

[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; 

Cảm ơn.

Trả lời

20

Bạn đang tìm kiếm scripted constant. Xem ví dụ sau:

[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, đó chính xác là những gì tôi cần. Nó đã làm việc. Cảm ơn nhiều. – wcc

Các vấn đề liên quan