Delphi 对ini文件的操作
界面如图:

代码如下:
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文件的操作的更多相关文章
- Delphi对ini文件的操作
一.INI文件的结构:; 注释[小节名]关键字=值 INI文件允许有多个小节,每个小节又允许有多个关键字, “=”后面是该关键字的值. 值的类型有三种:字符串.整型数值和布尔值.其中字符串存贮在INI ...
- delphi对ini文件的操作(转载 万一)
ini 文件操作记要(1): 使用 TIniFileunit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Gr ...
- Delphi关于记录文件的操作
http://www.cnblogs.com/railgunman/archive/2010/08/16/1801004.html Delphi关于记录文件的操作 本例子几个变量的说明TFileR ...
- delphi中ini 文件操作记要(1): 使用 TIniFile
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ...
- delphi读取ini文件
ini文件在系统配置及应用程序参数保存与设置方面,具有很重要的作用,所以可视化的编程一族,如vb.vc.vfp.delphi等都提供了读写ini文件的方法,其中delphi中操作ini文件,最为简洁, ...
- delphi 基础之三 文件流操作
文件流操作 Delphi操作流文件:什么是流?流,简单来说就是建立在面向对象基础上的一种抽象的处理数据的工具.在流中,定义了一些处理数据的基本操作,如读取数据,写入数据等,程序员是对流进行所有操作的, ...
- Delphi 实现Ini文件参数与TEdit和TCheckBox绑定(TSimpleParam)
在实际工作中,常遇到对Ini参数的修改,显示与保存问题. 如果手工写代码,会有很大的工作量. 本例把ini文件的参数与控件绑定起来,以达到方便使用的目的. 本例程共有2个单元 uSimpleParam ...
- C#实现.ini文件读写操作
1.ini文件是什么? 见百度百科:https://baike.baidu.com/item/ini%E6%96%87%E4%BB%B6/9718973?fr=aladdin 2.C#语 ...
- VC++ 实现INI文件读写操作
转载:https://blog.csdn.net/fan380485838/article/details/73188420 在实际项目开发中,会用ini配置文件,在此总结一下对ini读写操作 一:读 ...
随机推荐
- 20165306 Exp2 后门原理与实践
20165306 Exp2 后门原理与实践 实验内容 (1)使用netcat获取主机操作Shell,cron启动 (2)使用socat获取主机操作Shell, 任务计划启动 (3)使用MSF mete ...
- vs2013编译obs源码
obs源码下载 一种是在GitHub上下载最新的代码 git clone --recursive https://github.com/jp9000/obs-studio.git --recursiv ...
- 【Mac】【创建钥匙串】
1 Mac在钥匙串创建系统证书失败 https://blog.csdn.net/lllkey/article/details/79423596 问题: 在Eclipse的Debug,使用gdb的时候, ...
- Lombok之使用详解
前言 在Java中,封装是一个非常好的机制,最常见的封装莫过于get,set方法了,无论是Intellij idea 还是Eclipse,都提供了快速生成get,set方法的快捷键,使用起来很是方便, ...
- 实验七 《FBG》—-小学生课后习题答案原型设计
一.实验目的与要求 1.掌握软件原型开发技术 2.学习使用软件原型开发工具 二.实验内容与步骤 1.开发工具: 使用的工具:墨刀(APP端开发原型) 工具简介: 墨刀(MockingBot)是一款简单 ...
- linux下初始化mysql时报错
执行mysqld --initialize后报错 报错内容: 019-04-24 18:07:59 0 [Warning] TIMESTAMP with implicit DEFAULT value ...
- go安装和开发工具安装
go适合做什么 l 服务端开发 l 分布式系统 l 网络编程 l 区块链开发 l 内存KV数据库,例如boltDB.levelDB l 云平台 一 go安装 官网:https://golang.goo ...
- Django web框架-----Django连接本地现有mysql数据库
第一步:win10下载mysql5.7压缩包配置安装mysql,创建数据库或导入数据库 第二步:win10搭建django2.1.7开发环境,创建项目为mytestsite,创建应用app为quick ...
- fetch请求get方式以及post提交参数为formdata类型的数据
1.请求方式post,请求函数参数 _requestData(callback,_cityDt){ const switchIp = "http://192.168.43.103/api/p ...
- XCube和X组件的入门级使用教程
我也是一个入门级的初学者,在学习魔方的时候,很多不是很懂的地方,而网上的资料又比较少.尤其是Newlife的论坛打不开的情况下 所以就想着把这个初级项目做完后,做一个入门级教程.保证人人都看得懂(.^ ...