Delphi32.com - Home!
| Home/News | Downloads | Forums | D32 Magazine | Resources | Info and Facts |  
 
 TIniFile - Save Settings


The following information applies to:
  • VCL
  • Delphi (All Versions)
Steps, Assumptions, Procedures:
  1. Uses IniFiles.pas
Code:


const
    INI_FILE = 'MySettings.ini';
    SECTION = 'Init';

1.  procedure SaveFormSettings;
2.  var
3.      Settings: TIniFile;
4.  begin
5.          Settings := TIniFile.Create(INI_FILE);
7.          Settings.WriteString(SECTION,'MemoColor',ColorToString(Memo1.Color));
8.  end;


1.  procedure ReadFormSettings;
2.  var
3.      Settings: TIniFile;
4.  begin
5.          Settings := TIniFile.Create(INI_FILE);
7.          Memo1.Color := StringToColor(Settings.ReadString(SECTION,'MemoColor',''));
8.  end;
Results:
The SaveFormSettings procedure will write the string value equivelent of the current color of the Memo1 component to the MySettings.ini file in the Windows directory (the file will be automatically created if it doesn't exist).

The ReadFormSettings procedure will set the color of the Memo1 component to the color stored in the MySettings.ini file.
Explanation:
Call the first procedure (SaveFormSettings) in the OnClose event or in a save routine. Call the ReadFormSettings procedure in the OnCreate event or at the time of form initialization.

The settings
Notes:
  • The TRegIniFile class can be used in a very similar fashion and is recommended for 32-bit Windows applications.
  • You must add the IniFiles.pas file to your Uses clause in order to use the TIniFile class.


Submission Information:
Submitted by: Urban
E-Mail: urban@scc.net



 
 Hits/month  2,500,000+ 
 Downloads
 (Since May 2000)
 7,393,709 
 Total Files  6,023 
 Forum msgs  7,670 
 Articles/FAQs  70+/900+ 
Kylix
Tips n Tricks
FAQs
Knowledge Base
Bug Listings
Articles
Books
Newsgroups
Links
Submissions
Testimonials
Advertising
Contact Us
About Us
Search Amazon:
Top Selling Software at Amazon

| Home/News | Downloads | Forums | Resources | Info and Facts | Testimonials |
  Site Search:
 


Comments/Problems: Webmaster@delphi32.com
Copyright © 1998-2006, Delphi32.com. All rights reserved.
Terms of Use