ini 文件操作记要(2): 使用 TMemIniFile
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses
IniFiles;
var
ini: TMemIniFile;
procedure TForm1.FormCreate(Sender: TObject);
begin
ini := TMemIniFile.Create('c:\temp\test.ini');
end;
//写入
procedure TForm1.Button1Click(Sender: TObject);
begin
ini.WriteString('AAA','A1','AAA-String');
//其他也都和 IniFile 一样使用
// ini.WriteInteger();
// ini.WriteBool();
// ini.WriteDate();
// ini.WriteTime();
// ini.WriteDateTime();
// ini.WriteFloat();
// ini.WriteBinaryStream();
//ini.UpdateFile; //因为 TMemIniFile 是内存操作, 这样才能保存到文件
end;
//读出及其他
procedure TForm1.Button2Click(Sender: TObject);
var
s: string;
begin
s := ini.ReadString('AAA','A1','默认值');
ShowMessage(s); //AAA-String
//其他读入命令也都和 IniFile 一样使用
// ini.ReadInteger();
// ini.ReadBool();
// ini.ReadDate();
// ini.ReadTime();
// ini.ReadDateTime();
// ini.ReadFloat();
// ini.ReadBinaryStream();
//还有四个常用方法也是和 IniFile 一样的
//ini.DeleteKey();
//ini.EraseSection();
//ini.ReadSection();
//ini.ReadSections();
//另外有三个 IniFile 中没有的方法也容易使用
//ini.GetStrings(List: TStrings);
//ini.SetStrings(List: TStrings);
//ini.Rename(const FileName: string; Reload: Boolean);
//其中 Rename 中的第二个 Boolean 参数如果为 True 将会刷新读入
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
ini.Free;
end;
end.
ini 文件操作记要(2): 使用 TMemIniFile的更多相关文章
- ini 文件操作记要(1): 使用 TIniFile
ini 文件操作记要(1): 使用 TIniFile unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Class ...
- delphi中ini 文件操作记要(1): 使用 TIniFile
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ...
- ini文件操作
Config.ini 文件操作 [SYS] sysname=hy company=hyhy tel=2 using System; using System.Collections.Generic; ...
- winform INI文件操作辅助类
using System;using System.Runtime.InteropServices;using System.Text; namespace connectCMCC.Utils{ // ...
- Ini文件操作类
/// <summary> /// Ini文件操作类 /// </summary> public class Ini { // 声明INI文件的写操作函数 WritePriva ...
- Delphi ini文件操作 TIniFile、TMemIniFile
1.使用TIniFile unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Co ...
- C# ini文件操作【源码下载】
介绍C#如何对ini文件进行读写操作,C#可以通过调用[kernel32.dll]文件中的 WritePrivateProfileString()和GetPrivateProfileString()函 ...
- C#读写ini文件操作
ini文件,是windows操作系统下的配置文件,ini文件是一种按照特点方式排列的文本文件,它的构成分为三部分,结构如下: [Section1] key 1 = value2 key 1 = val ...
- C# Ini文件操作
在开源中国看到的操作ini文件的,写的还不看,留着以后用 using System; using System.IO; using System.Runtime.InteropServices; us ...
随机推荐
- thinkphp 表单一些
<tr class="tr rt"> <td colspan="4" class="lt"> <select ...
- [self.view addSubview:vc2.view]程序崩溃的解决办法
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. UIButt ...
- Java experts blog
https://blogs.oracle.com/poonam/ https://blogs.oracle.com/poonam/entry/updates_to_the_java_troublesh ...
- form action中如何填写相对目录
举个例子,你在web-root文件夹有个a.html需要向/web-root/jsp/b.jsp提交form,怎么做 网上看到了一个解决方案,但是要求a是jsp页面而不是html页面 <%!St ...
- dp之二维背包poj2576
题意:有一群sb要拔河,把这群sb分为两拨,两拨sb数只差不能大于1,输出这两拨人的体重,小的在前面...... 思路:把总人数除2,总重量除2,之后你会发现就是个简单的二维背包,有两个限制..... ...
- logback日志模板与详解
<pattern>的转换符说明: (这部分引用自http://aub.iteye.com/blog/1103685)转换符 作用 c {length } lo {length } logg ...
- 一款纯css3实现的超炫动画背画特效
之前为大家介绍了很多款由纯css3实现的特效.今天要再给大家带来一款纯css3实现的超炫动画背画特效.代码非常简单,没有引用任何其它js代码.css代码也不多.效果非常炫.一起看下效果图: 在线预览 ...
- java Spring 事务的初次使用与验证
事务,只要是为了保证数据的原子性.避免出现脏数据. 下面来讲解下spring是如何使用事务的. 1.配置事务.这里采用的是注解的模式 <!-- 配置事务管理器 ,如果你暂时未使用到事务可以不配置 ...
- SQL Server 2008 压缩日志
USE [master]GOALTER DATABASE DNName SET RECOVERY SIMPLE WITH NO_WAITGOALTER DATABASE DNName SET RECO ...
- BusyBox rcS&fstab配置
rcS为系统初始化脚本,完成最开始的一些配置工作,可开启应用程序. #!/bin/shmount -a ;mount文件,要mount的文件有fstab指定. . /etc/profile ...