Delphi INI文件保存与读取
//需要引用IniFiles
uses
system.IniFiles;
//保存INI配置文件
procedure TForm1.btnSaveClick(Sender: TObject);
var
myIniFile: TIniFile;
filepath: string;
begin
filepath := ExtractFilePath(Application.Exename) + 'DBConfig.ini'; //取得ini文件的路径
myIniFile := TIniFile.Create(filepath);
try
myIniFile.WriteString('DBConf', 'Server', edtServer.Text); //服务器地址
myIniFile.WriteString('DBConf', 'Port', edtPort.Text); //数据库端口
myIniFile.WriteString('DBConf', 'Database', edtDatabase.Text); //数据库名
myIniFile.WriteString('DBConf', 'User', edtUser.Text); //登录用户名
myIniFile.WriteString('DBConf', 'Password', edtPwd.Text); //登录密码
ShowMessage('保存成功');
finally
myIniFile.Free;
end;
end;
//载入INI配置文件
procedure TForm1.btnLoadClick(Sender: TObject);
var
myIniFile: TIniFile;
filepath: string;
begin
filepath := ExtractFilePath(Application.Exename) + 'DBConfig.ini'; //取得ini文件的路径
myIniFile := TIniFile.Create(filepath);
try
ListBox1.Clear;
ListBox1.Items.Add('服务器:' + myIniFile.ReadString('DBConf', 'Server', '')); //服务器地址
ListBox1.Items.Add('端口:' + myIniFile.ReadString('DBConf', 'Port', '')); //数据库端口
ListBox1.Items.Add('数据库:' + myIniFile.ReadString('DBConf', 'Database', '')); //数据库名
ListBox1.Items.Add('用户名:' + myIniFile.ReadString('DBConf', 'User', '')); //登录用户名
ListBox1.Items.Add('密码:' + myIniFile.ReadString('DBConf', 'Password', '')); //登录密码
finally
myIniFile.Free;
end;
end;
界面效果

Delphi INI文件保存与读取的更多相关文章
- 【经验】Delphi INI文件保存与读取
//需要引用IniFiles uses system.IniFiles; //保存INI配置文件 procedure TForm1.btnSaveClick(Sender: TObject); var ...
- delphi INI文件
INI 文件读写 filecreate('路径加文件名')://创建一个文件. (1) INI文件的结构: ;这是关于INI文件的注释部分 [节点] 关键字=值 ... INI文件允许有多个节点,每个 ...
- Delphi INI 文件读写
delphi中,配置文件的相关操作. () INI文件的结构: ;这是关于INI文件的注释部分 [节点] 关键字=值 ... INI文件允许有多个节点,每个节点又允许有多个关键字, “=”后面是该关键 ...
- Delphi ini文件读写
参考:http://www.cnblogs.com/zhangzhifeng/archive/2011/12/01/2270267.html 一.ini文件的结构 ;这是关于 ini 文件的注释 [节 ...
- python ini文件内容的读取
(1)新建一个项目,再次新建一个文件 test_cfg.ini (2)再次新建 get_test_cfg.py,用来读取/写入/更改 ini的文件内容 #!/usr/bin/env python # ...
- Delphi ini文件操作 TIniFile、TMemIniFile
1.使用TIniFile unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Co ...
- Android文件保存和读取
public class DataActivity extends Activity { private EditText filenameText; private EditText content ...
- C#读取ini文件的方法
最近项目用到ini文件,读取ini文件,方法如下: using System; using System.Collections.Generic; using System.Linq; using S ...
- Protobuf for Python测试保存和读取文件
安装pip, setuptools, and wheel 如果已经从python.org,安装啦Python 2 >=2.7.9 or Python 3 >=3.4 ,那么就已经有啦pip ...
随机推荐
- SpringBoot thymeleaf模板页面没提示,SpringBoot thymeleaf模板插件安装
SpringBoot thymeleaf模板插件安装 SpringBoot thymeleaf模板Html页面没提示 SpringBoot thymeleaf模板页面没提示 SpringBoot t ...
- C++定义字符数组
问:C++中定义字符型数组时'\0'是不是也占一位?是不是定义char a[5],只能有4个字符?那计算字符长度时又否忽略'\0'? 答: C++中定义字符型数组时'\0'是不是也占一位?是不是定义c ...
- 服务器虚拟化ESXi 5.5安装过程
研究服务器虚拟化实践小结: 实验服务器硬件: 主板 华硕P8B-C/2L CPU Intel Xeon E3-1230 V2 3.3GHz RAM 8G ECC 1600MHz 硬盘 2T 2块 软件 ...
- 工具 - vConsole调试工具 在项目中的应用
最近做移动端项目比较多,电脑上开发完了上真机必现问题,但是真机上又看不了代码很捉急啊有没有. 这两天才发现这个腾讯良品vConsole,以前开发小程序见过,但没想到他竟然还能被应用到我们的h5页面中, ...
- centos7 安装zookeeper3.4.8集群
1.下载上传文件到centos中 2.解压文件夹 3.cd conf 文件下,cp zoo_sample.cfg zoo.cfg 4.vim zoo.cfg # The number of mil ...
- C++文件流操作
#include <iostream> #include <fstream> #include<iostream> using namespace std; int ...
- day_5.07py
正则:
- B - Image Perimeters
Technicians in a pathology lab analyze digitized images of slides. Objects on a slide are selected f ...
- js document.activeElement 获得焦点的元素
<body> <input type="text" id="test" value="ajanuw"> <sc ...
- 180425、cookie工具类
package com.thinkgem.jeesite.common.utils; import java.io.UnsupportedEncodingException; import java. ...