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读写操作 一:读 ...
随机推荐
- 解决win10 蓝牙设备只能配对无法连接 ,并且删除设备无效的问题
系统环境: win10家庭版 dell本 问题描述:蓝牙设备(比如蓝牙键盘,蓝牙音箱)出现无法连接的情况,打算删除已配对的设备,再重新配对连接.但删除设备后重启蓝牙,那些原本被删除的设备又自动配对上, ...
- Clover 安装 Mac 系统更新 (原版黑苹果)
关于使用原版镜像(即 .dmg )安装黑苹果的升级,笔者写写自身经验吧. 在Clover启动的界面中与Mac OS有关的启动菜单有以下这些: Boot FileVault Prebooter from ...
- WEB前端基础知识点
因为要告知浏览器的解析器用什么文档标准解析这个文档,所以在文档的开头要写上文档类型声明,H5的文档类型声明要比H4文档类型声明简洁的多.因为H5不基于SGML(标准通用标记语言),所以不需要对DTD文 ...
- testng.xml中groups标签使用
XML配置如下: <?xml version="1.0" encoding="UTF-8"?> <suite name="suite ...
- Tomcat性能优化(转载)
出处:微信订阅号GitChat精品课程 — Tomcat性能优化 Tomcat 简单介绍 Sun 公司创建了第一个 Servlet 容器,即 Java Web Server,但 JWS 只是为了演示 ...
- VS code 推荐插件
vs code 中eslint语法检测,保存即可格式化 具体查看:(https://www.jianshu.com/p/23a5d6194a4b) { // vscode默认启用了根据文件类型自动设置 ...
- CSS清除浮动的一种简便的方法
在使用的浮动的元素的父元素添加该CSS样式 .clear{ overflow: auto; }
- sysbench工具安装使用
一.sysbench简介 Sysbench是一款开源的.跨平台的.模块化的.多线程的性能测试工具,通过高负载地运行在数据库上,可以执行CPU.内存.线程.IO.数据库等方面的性能测试.用于评估操作系统 ...
- 站在Web3.0 理解IPFS是什么
尽管网络上,已经有不少文章讨论IPFS,不过真正讲明白IPFS想做什么的很少,文本尝试站在未来Web3.0的高度来看看IPFS究竟用来解决什么问题. DApp 的缺陷 对区块链有所了解的同学,知道区块 ...
- 使用cookie保存用户名和密码
效果图如下 从数据库中随意使用一个账号登录 登陆成功来到人中心 返回登录界面 实现代码如下 package com.test.controller; import java.io.IOExceptio ...