Guest User

Save Inno Setup Custom Form field values to an INI file

a guest
Feb 23rd, 2012
664
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. { AuthForm_NextkButtonClick }
  2.  
  3. function AuthForm_NextButtonClick(Page: TWizardPage): Boolean;
  4. begin
  5. Result := True;
  6. end;
  7.  
  8. [INI]
  9. Filename: {app}prefs.ini; Section: AUTH; Key: USERNAME; String:
  10. Filename: {app}prefs.ini; Section: AUTH; Key: PASSWORD; String:
  11.  
  12. AuthPage := CreateInputQueryPage(wpWelcome,
  13. 'Account Information', 'Please enter your Account Information',
  14. '');
  15. AuthPage.Add('Username:', False);
  16. AuthPage.Add('Password:', True);
  17.  
  18. SetIniString('AUTH', 'USERNAME', AuthPage.Values[0], '{app}prefs.ini')
  19. SetIniString('AUTH', 'PASSWORD', AuthPage.Values[1], '{app}prefs.ini')
  20.  
  21. ; Script generated by the Inno Setup Script Wizard.
  22. ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
  23.  
  24. [Setup]
  25. ; NOTE: The value of AppId uniquely identifies this application.
  26. ; Do not use the same AppId value in installers for other applications.
  27. ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
  28. AppId={{82C8C949-44A8-49C4-8CED-8DD0ACD0DCCF}
  29. AppName=My Program
  30. AppVerName=My Program 1.5
  31. AppPublisher=My Company, Inc.
  32. AppPublisherURL=http://www.example.com/
  33. AppSupportURL=http://www.example.com/
  34. AppUpdatesURL=http://www.example.com/
  35. DefaultDirName={pf}My Program
  36. DefaultGroupName=My Program
  37. OutputBaseFilename=setup
  38. Compression=lzma
  39. SolidCompression=yes
  40.  
  41. [Languages]
  42. Name: "english"; MessagesFile: "compiler:Default.isl"
  43.  
  44. [Tasks]
  45. Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
  46.  
  47. [Files]
  48. Source: "C:utilinnosetup5.3.7ExamplesMyProg.exe"; DestDir: "{app}"; Flags: ignoreversion
  49.  
  50. ; NOTE: Don't use "Flags: ignoreversion" on any shared system files
  51.  
  52. [Icons]
  53. Name: "{group}My Program"; Filename: "{app}MyProg.exe"
  54. Name: "{commondesktop}My Program"; Filename: "{app}MyProg.exe"; Tasks: desktopicon
  55.  
  56. [Run]
  57. Filename: "{app}MyProg.exe"; Description: "{cm:LaunchProgram,My Program}"; Flags: nowait postinstall skipifsilent
  58.  
  59. [INI]
  60. Filename: {app}prefs.ini; Section: AUTH; Key: USERNAME; String: {code:GetUserName}
  61. Filename: {app}prefs.ini; Section: AUTH; Key: PASSWORD; String: {code:GetPassword}
  62.  
  63.  
  64. [code]
  65. var
  66. AuthPage : TInputQueryWizardPage;
  67.  
  68. procedure InitializeWizard;
  69. begin
  70. AuthPage := CreateInputQueryPage(wpWelcome,
  71. 'Account Information', 'Please enter your Account Information',
  72. '');
  73. AuthPage.Add('Username:', False);
  74. AuthPage.Add('Password:', True);
  75. end;
  76.  
  77. function AuthForm_NextButtonClick(Page: TWizardPage): Boolean;
  78. begin
  79. Result := True;
  80. end;
  81.  
  82. function GetUserName(Param: String): string;
  83. begin
  84. result := AuthPage.Values[0];
  85. end;
  86.  
  87. function GetPassword(Param: String): string;
  88. begin
  89. result := AuthPage.Values[1];
  90. end;
Advertisement
Add Comment
Please, Sign In to add comment