I have to save username and password which typed by user to text file but it create text file and save the texts before user type it. (So empty text file is created).
I think I have to do somethings with procedure but although I search the solution, I couldn't find.
My code:
[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's 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;
You are creating the input page when installer starts and immediately saving the fields into text file.
You need to wait while user enters the data and clicks Next button on 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;
And few tips: saving names/passwords is not safe! Also using hardcoded path is reallly unusual...