界面如图:

代码如下:

 unit Unit1;

 interface

 uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls,IniFiles; //添加库 IniFiles type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
CheckBox1: TCheckBox;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1;
var
filepath :string;
myinifile : TIniFile;
implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject);
begin
try
filepath := ExtractFilePath(Paramstr()) + 'serverlist.ini'; //获取当前路径+文件名
myinifile := Tinifile.Create(filepath); //创建文件
except
ShowMessage('LOADINI打开配置文件失败');
Exit;
end;
{写入}
myinifile.WriteString('ListServer1','ServerCount','');
myinifile.WriteString('ListServer1','Name0','');
myinifile.WriteString('ListServer1001','ServerCount','');
myinifile.WriteString('ListServer1001','Name0',Edit1.Text);
myinifile.WriteString('ListServer1001','IP0',Edit2.Text);
myinifile.WriteInteger('ListServer1001','Port0',StrToInt(Edit3.Text));
myinifile.WriteBool('Battle','Enable',False); myinifile.WriteInteger('Resolution','width',);
myinifile.WriteInteger('Resolution','height',);
if CheckBox1.Checked = True then
myinifile.WriteBool('WINDOW_MODE','MODE',True)
else
myinifile.WriteBool('WINDOW_MODE','MODE',False);
ShowMessage('写入成功');
end; procedure TForm1.Button2Click(Sender: TObject);
begin
try
filepath := ExtractFilePath(Paramstr()) + 'serverlist.ini'; //获取当前路径+文件名
myinifile := Tinifile.Create(filepath); //创建文件
except
ShowMessage('LOADINI打开配置文件失败');
Exit;
end;
{读取}
Edit1.Text:= myinifile.ReadString('ListServer1001','Name0','');
Edit2.Text:= myinifile.ReadString('ListServer1001','IP0','');
Edit3.Text:= myinifile.ReadString('ListServer1001','Port0','');
end; end.

Delphi 对ini文件的操作的更多相关文章

  1. Delphi对ini文件的操作

    一.INI文件的结构:; 注释[小节名]关键字=值 INI文件允许有多个小节,每个小节又允许有多个关键字, “=”后面是该关键字的值. 值的类型有三种:字符串.整型数值和布尔值.其中字符串存贮在INI ...

  2. delphi对ini文件的操作(转载 万一)

    ini 文件操作记要(1): 使用 TIniFileunit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Gr ...

  3. Delphi关于记录文件的操作

    http://www.cnblogs.com/railgunman/archive/2010/08/16/1801004.html Delphi关于记录文件的操作   本例子几个变量的说明TFileR ...

  4. delphi中ini 文件操作记要(1): 使用 TIniFile

    unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ...

  5. delphi读取ini文件

    ini文件在系统配置及应用程序参数保存与设置方面,具有很重要的作用,所以可视化的编程一族,如vb.vc.vfp.delphi等都提供了读写ini文件的方法,其中delphi中操作ini文件,最为简洁, ...

  6. delphi 基础之三 文件流操作

    文件流操作 Delphi操作流文件:什么是流?流,简单来说就是建立在面向对象基础上的一种抽象的处理数据的工具.在流中,定义了一些处理数据的基本操作,如读取数据,写入数据等,程序员是对流进行所有操作的, ...

  7. Delphi 实现Ini文件参数与TEdit和TCheckBox绑定(TSimpleParam)

    在实际工作中,常遇到对Ini参数的修改,显示与保存问题. 如果手工写代码,会有很大的工作量. 本例把ini文件的参数与控件绑定起来,以达到方便使用的目的. 本例程共有2个单元 uSimpleParam ...

  8. C#实现.ini文件读写操作

    1.ini文件是什么?        见百度百科:https://baike.baidu.com/item/ini%E6%96%87%E4%BB%B6/9718973?fr=aladdin 2.C#语 ...

  9. VC++ 实现INI文件读写操作

    转载:https://blog.csdn.net/fan380485838/article/details/73188420 在实际项目开发中,会用ini配置文件,在此总结一下对ini读写操作 一:读 ...

随机推荐

  1. [IoC容器Unity]第三回:依赖注入

    1.引言 上节介绍了,Unity的Lifetime Managers生命周期,Unity具体实现依赖注入包含构造函数注入.属性注入.方法注入,所谓注入相当赋值,下面一个一个来介绍. 2.构造函数注入 ...

  2. Apache 配置多个端口多站点(Linux)

    for apache2 configuration: by default, apache is configured 80 port for the default web site. follow ...

  3. Shiro框架配置-applicationContext里面的(仅提供借鉴)

    <!-- 配置自定义realm --> <bean id="shiroAuthRealm" class="com.sykj.realm.ShiroAut ...

  4. (5)TCP和UDP协议

    TCP(Transmission Control Protocol)可靠的.面向连接的协议(eg:打电话).传输效率低全双工通信(发送缓存&接收缓存).面向字节流.使用TCP的应用:Web浏览 ...

  5. ArcSDE10.1配置Oracle 监听器来使用SQL操作ST_Geometry(个人改动版)

    发了两天的时间来解决配置Oracle 监听器来使用SQL操作ST_Geometry的配置,网上搜索一大片,结果真正找到的只有方法可用,下面把这个方法我个人在总结下. ArcSDE10.1配置Oracl ...

  6. 树莓派 连接 JY901(MPU9250) python 代码

    先说BUG,最近要做项目需要树莓派和陀螺仪,资金充足的话肯定是买一个硬件卡尔曼滤波的传感器类似JY901模块,资金不足的就买MPU6050. 网上关于MPU6050在树莓派上的代码还能用,关于JY90 ...

  7. shell脚本 快照还原Hbase数据库

    #!/bin/bash for i in $(cat ./hbaseTable);do echo "disable '$i'" | hbase shellecho "re ...

  8. composer常用的一些命令\参数\说明

    安装 curl -sS https://getcomposer.org/installer | php 或者 php -r "readfile('https://getcomposer.or ...

  9. TP5.0 PHPExcel 数据表格导出导入(原)

    今天看的是PHPExcel这个扩展库,Comporse 下载不下来,最后只能自己去github里面手动下载,但有一个问题就是下载下来的PHPExcel没有命名空间,所以框架里面的use根本引入不进去, ...

  10. Nullable object must have a value

    有一个linq查询,由inner join改成left join, 对于有空值,就会出现Nullable object must have a value 的错误. 原来的查询: var qry = ...