在Inno Setup中将输入的文本保存到TXT文件 [英] Save entered text to TXT file in Inno Setup

查看:435
本文介绍了在Inno Setup中将输入的文本保存到TXT文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须将用户键入的用户名和密码保存到文本文件中,但是它会创建文本文件并在用户键入之前保存文本. (因此将创建一个空文本文件).

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.

我的代码:

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

这篇关于在Inno Setup中将输入的文本保存到TXT文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆