Save entered text to TXT file in Inno Setup

I need to save the username and password that the user entered into the text file, but it creates the text file and saves the texts before the user enters them. (This creates an empty text file).

I think I need to do something with the procedure, but although I was looking for a solution, I could not find.

My code is:

[Code]
var
  Page: TInputQueryWizardPage;
  username: String;
  password: String;

procedure InitializeWizard;
begin
  { Create the page }
  Page := CreateInputQueryPage(wpWelcome,
    'Username & Password', 'Username like : e201600',
    'Please enter your username and password.');
  { Add items (False means it not a password edit) }
  Page.Add('Username:', False);
  Page.Add('Password:', True);
  { Set initial values (optional) }
  Page.Values[0] := ExpandConstant('hello5');
  Page.Values[1] := ExpandConstant('');
  { Read values into variables }
  username := Page.Values[0];
  password := Page.Values[1];
  SaveStringToFile('c:\filename.txt', username+#13#10+password+#13#10, False);
end;
+1
source share
1 answer

You create an input page when the installer starts and immediately save the fields to a text file.

You need to wait until the user enters data and clicks the "Next" button on the correct page:

function NextButtonClick(CurPageID: Integer): Boolean;
begin
  if(CurPageID = Page.ID) then
  begin
    { Process the page }
    { Read values into variables }
    username := Page.Values[0];
    password := Page.Values[1];
    SaveStringToFile('c:\filename.txt', username+#13#10+password+#13#10, False);
  end;

 Result := True;
end;

: / ! ...

+3

Source: https://habr.com/ru/post/1651371/


All Articles