【问题标题】:Save entered text to TXT file in Inno Setup在 Inno Setup 中将输入的文本保存到 TXT 文件
【发布时间】:2015-03-12 01:00:18
【问题描述】:

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

我想我必须对程序做一些事情,但是虽然我搜索了解决方案,但我找不到。

我的代码:

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

【问题讨论】:

    标签: inno-setup pascalscript


    【解决方案1】:

    您正在安装程序启动时创建输入页面并立即将字段保存到文本文件中。

    您需要等待用户输入数据并点击正确页面上的下一步按钮:

    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;
    

    还有一些提示:保存名称/密码并不安全!同样使用硬编码路径真的很不寻常......

    【讨论】:

    • 非常感谢!实际上,在保存用户名和密码后,我的 python 程序对其进行了加密。可以吗?我将按照您的建议更改硬编码路径。解决方案的完整代码(有人可能需要):codepad.org/q2iAuF5O
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-28
    • 2022-10-19
    • 1970-01-01
    • 2019-06-21
    • 2012-04-16
    相关资源
    最近更新 更多