In the Inifiles unit, there are three three main operations classes Tcustominifile, Tmeminifile, and tinifile that read the INI file, which, under the Windows System compilation, Tcustominifile are the base classes of Tmeminifile and Tinifile, respectively, The only difference between the two operation classes, Tmeminifile and Tinifile, in the Windows system is that the storage of tmeninifile costs is larger than tinifile. There are several important ways in which tcustominifile
UnitUnit1;InterfaceusesWindows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms, Dialogs, Stdctrls;typeTForm1 =class(Tform) Button1:tbutton; Button2:tbutton;procedureFormcreate (Sender:tobject);procedureFormdestroy (Sender:tobject);procedureButton1Click (Sender:tobject);procedureButton2click (Sender:tobject);Private{Private declarations} Public{Public declarations}End;varForm1:tform1;Implementation{$R *.DFM}usesInifiles;varIni:tmeminifile;procedureTform1.formcreate (Sender:tobject);beginINI: = tmeminifile.create (' C:\temp\test.ini ');End;WriteprocedureTform1.button1click (Sender:tobject);beginIni. WriteString (' AAA ',' A1 ',' Aaa-string ');All the others are used like IniFile.Ini. Writeinteger ();Ini. Writebool ();Ini. Writedate ();Ini. Writetime ();Ini. Writedatetime ();Ini. Writefloat ();Ini. Writebinarystream ();Ini. Updatefile; Because Tmeminifile is a memory operation, it can be saved to a fileEnd;read out and otherprocedureTform1.button2click (Sender:tobject);varSstring;beginS: = ini. ReadString (' AAA ',' A1 ',' Default value '); ShowMessage (s);Aaa-stringOther read-in commands are also used in the same way as IniFileIni. Readinteger ();Ini. Readbool ();Ini. Readdate ();Ini. Readtime ();Ini. Readdatetime ();Ini. Readfloat ();Ini. Readbinarystream ();Four other common methods are the same as IniFile.Ini. DeleteKey ();Ini. Erasesection ();Ini. Readsection (); //ini. Readsections (); //Three other methods not found in IniFile are also easy to use //ini. Getstrings (list:tstrings); //ini. Setstrings (list:tstrings); //ini. Rename (const filename:string; Reload:boolean); //The second Boolean parameter in Rename If True will refresh read-in End ; procedure Tform1.formdestroy (sender:tobject); begin INI. Free; end ; end .
Tmeminifile and Tinifile