如果存在填充了所有字段的ini文件,则不显示用户信息页面

时间:2014-08-07 13:03:15

标签: inno-setup

我的页面上有一个代码,用于提供有关用户的信息,该用户一旦填充就会写入写入ini文件的数据。 将永远是打开安装程序,可以读取文件ini填充用户数据,并填写回来不显示用户信息页面?

换句话说...... 打开安装程序,用户信息页面填充字段 enter image description here

// create the input query page
  InputPage := CreateInputQueryPage(wpWelcome, 'User Information',' Add the following information! ',' Please fill in the following fields to keep updated database users.');
  // add an edit box and remember its index; False means it is not a password edit
  //name
  EditIndex1 := InputPage.Add('Name:', False);

  // bind events to the just added edit box
  //InputPage.Edits[EditIndex1].OnChange := @MyEditChange;
  InputPage.Edits[EditIndex1].OnKeyPress := @MyEditKeyPress;

  //labels: SetBounds(aLeft, aTop, aWidth, aHeight);
  InputPage.PromptLabels[EditIndex1].SetBounds(10,40,90,20);
  InputPage.Edits[EditIndex1].SetBounds(100,40,240,40);
  InputPage.Edits[EditIndex1].MaxLength:=35

  //username
  EditIndex2 := InputPage.Add('Username:', False);
  InputPage.Values[EditIndex2]:= ExpandConstant('{username}');
  InputPage.PromptLabels[EditIndex2].SetBounds(10,65,90,20);
  InputPage.Edits[EditIndex2].SetBounds(100,65,60,40);
  InputPage.Edits[EditIndex2].MaxLength:=7
  InputPage.Edits[EditIndex2].ReadOnly:=true;
  InputPage.Edits[EditIndex2].Color:=clBtnFace;

  //hostname
  EditIndex3 := InputPage.Add('Computername:', False);
  InputPage.Values[EditIndex3]:= ExpandConstant('{computername}');
  InputPage.PromptLabels[EditIndex3].SetBounds(10,90,90,20);
  InputPage.Edits[EditIndex3].SetBounds(100,90,100,40);
  InputPage.Edits[EditIndex3].MaxLength:=15
  InputPage.Edits[EditIndex3].ReadOnly:=true;
  InputPage.Edits[EditIndex3].Color:=clBtnFace;

  //e-mail
  EditIndex4 := InputPage.Add('E-mail:', False);
  InputPage.PromptLabels[EditIndex4].SetBounds(10,115,90,20);
  InputPage.Edits[EditIndex4].SetBounds(100,115,130,40);
  InputPage.Edits[EditIndex4].OnKeyPress:=@isAt;

  //@
  EditIndex5 := InputPage.Add('@', False);
  InputPage.PromptLabels[EditIndex5].SetBounds(235,115+3,10,20);
  InputPage.Edits[EditIndex5].SetBounds(250,115,70,40);
  InputPage.Edits[EditIndex5].OnKeyPress:=@noAt;
  InputPage.Edits[EditIndex5].MaxLength:=10;
  InputPage.Edits[EditIndex5].Text:='';

  //phone
  EditIndex6 := InputPage.Add('Phone:', False);
  InputPage.Edits[EditIndex6].OnKeyPress:=@NumbersOnly;
  InputPage.PromptLabels[EditIndex6].SetBounds(10,140,90,20);
  InputPage.Edits[EditIndex6].SetBounds(100,140,80,40);
  InputPage.Edits[EditIndex6].MaxLength:=9

  //extension
  EditIndex7 := InputPage.Add('Extension:', False);
  InputPage.Edits[EditIndex7].OnKeyPress:=@NumbersOnly;
  InputPage.PromptLabels[EditIndex7].SetBounds(10,165,90,20);
  InputPage.Edits[EditIndex7].SetBounds(100,165,60,40);
  InputPage.Edits[EditIndex7].MaxLength:=5

  //mobile
  EditIndex8 := InputPage.Add('Mobile:', False);
  InputPage.Edits[EditIndex8].OnKeyPress:=@NumbersOnly;
  InputPage.PromptLabels[EditIndex8].SetBounds(10,190,90,20);
  InputPage.Edits[EditIndex8].SetBounds(100,190,80,40);
  InputPage.Edits[EditIndex8].MaxLength:=9

end;

并创建INI文件

procedure CurStepChanged(CurStep: TSetupStep);
var
  I: Integer;
  FileName, DateTime: String;

begin
DateTime:=GetDateTimeString('dd/mm/yyyy hh:nn', '-', ':');

For I:=0 to WizardForm.ComponentsList.Items.Count - 1 do
      If WizardForm.ComponentsList.Checked[I] then
  // if the installation has just finished, save the edit box text into a file

    case CurStep of
        ssInstall :
      SaveStringToFile(ExpandConstant('C:\dir\User.ini'), '[Date/Time] ' + DateTime + #13#10 + '[Version/Build] 2.4_4.2.3_rev4_25Jul14' + #13#10 + '[Name] ' + InputPage.Edits[EditIndex1].Text + #13#10 + '[Username] ' + InputPage.Edits[EditIndex2].Text + #13#10 + '[Computername] ' + InputPage.Edits[EditIndex3].Text + #13#10 + '[E-mail] ' + InputPage.Edits[EditIndex4].Text +
      '@' + InputPage.Edits[EditIndex5].Text + #13#10 + '[Phone] ' + InputPage.Edits[EditIndex6].Text + #13#10 + '[Extension] ' + InputPage.Edits[EditIndex7].Text + #13#10 + '[Mobile] ' + InputPage.Edits[EditIndex8].Text + #13#10 + #13#10, True)
  end;
end;

enter image description here

下次运行安装程序时,它会从ini读取信息,如果字段未填充,则会显示用户信息页面。

可以帮到我吗?罐。

0 个答案:

没有答案