Delphi operation on INI file

Source: Internet
Author: User

Interface

The code is as follows:

1 UnitUnit1;2 3 Interface4 5 uses6 winapi.windows, Winapi.messages, System.sysutils, System.variants, system.classes, Vcl.graphics ,7Vcl.controls, Vcl.forms, Vcl.dialogs, vcl.stdctrls,inifiles;//Add library Inifiles8 9 typeTenTForm1 =class(Tform) One Button1:tbutton; A Button2:tbutton; - Label1:tlabel; - Label2:tlabel; the Label3:tlabel; - Label4:tlabel; - Edit1:tedit; - Edit2:tedit; + Edit3:tedit; - Checkbox1:tcheckbox; +     procedureButton1Click (sender:tobject); A     procedureButton2click (sender:tobject); at   Private -     {Private Declarations} -    Public -     {Public Declarations} -   End; -  in var - Form1:tform1; to var +FilePath:string; - Myinifile:tinifile; the Implementation *  $ {$R *.DFM}Panax Notoginseng  - procedureTform1.button1click (sender:tobject); the begin + Try AFilePath: = Extractfilepath (Paramstr (0)) +'Serverlist.ini';//get current path + file name theMyinifile: = Tinifile.Create(filepath);//Create a file + except -ShowMessage ('Loadini Opening configuration file failed'); $ Exit; $ End; -     {Write} -Myinifile. WriteString ('ListServer1','Servercount','1'); theMyinifile. WriteString ('ListServer1','NAME0','1'); -Myinifile. WriteString ('ListServer1001','Servercount','1');WuyiMyinifile. WriteString ('ListServer1001','NAME0', edit1.text); theMyinifile. WriteString ('ListServer1001','IP0', edit2.text); -Myinifile. Writeinteger ('ListServer1001','Port0', Strtoint (Edit3.text)); WuMyinifile. Writebool ('Battle','Enable', False); -  AboutMyinifile. Writeinteger ('Resolution','width',1024x768); $Myinifile. Writeinteger ('Resolution','Height',768); -     ifcheckbox1.checked = True Then -Myinifile. Writebool ('Window_mode','MODE', True) -     Else AMyinifile. Writebool ('Window_mode','MODE', False); +ShowMessage ('Write Success'); the End; -  $ procedureTform1.button2click (sender:tobject); the begin the Try theFilePath: = Extractfilepath (Paramstr (0)) +'Serverlist.ini';//get current path + file name theMyinifile: = Tinifile.Create(filepath);//Create a file - except inShowMessage ('Loadini Opening configuration file failed'); the Exit; the End; About     {Read} theEdit1.text:= Myinifile. ReadString ('ListServer1001','NAME0',"'); theEdit2.text:= Myinifile. ReadString ('ListServer1001','IP0',"'); theEdit3.text:= Myinifile. ReadString ('ListServer1001','Port0',"'); + End; -  the End.

Delphi operation on INI file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.