手机
当前位置:查字典教程网 >编程开发 >Delphi >delphi建立、读取、存贮INI文件的方法《三》
delphi建立、读取、存贮INI文件的方法《三》
摘要:从.INI文件中获取字符串varstrResult:pchar;beginGetPrivateProfileString(´wi...

从.INI文件中获取字符串

var

strResult:pchar;

begin

GetPrivateProfileString(

´windows´,//[]中标题的名字

´NullPort´,//=号前的名字

´NIL´,//如果没有找到字符串时,返回的默认值

strResult,//存放取得字符

100,//取得字符的允许最大长度

´c:forwin95win.ini´//调用的文件名

);

edit1.text:=strResult;//显示取得字符串

从.INI文件中获取整数

edit1.text:=inttostr(GetPrivateProfileInt(

´intl´,//[]中标题的名字

´iCountry´,//=号前的名字

0,//如果没有找到整数时,返回的默认值

´c:forwin95win.ini´//调用的文件名

));

向.INI文件写入字符串

WritePrivateProfileString(

´windows´,//[]中标题的名字

´load´,//要写入“=”号前的字符串

´accca´,//要写入的数据

´c:forwin95win.ini´//调用的文件名

);

向.INI文件写入整数

WritePrivateProfileSection(

´windows´,//[]中标题的名字

´read=100´,//要写入的数据

´c:forwin95win.ini´//调用的文件名

);

上面的方法是调用API函数,下面介绍另一种不用API从.INI文件中获取字符的方法

varMyIni:TIniFile;

begin

MyIni:=TIniFile.Create(´WIN.INI´);//调用的文件名

edit1.text:=MyIni.ReadString(´Desktop´,´Wallpaper´,´´);//取得字符

end;

向.INI文件中写入字符的方法

varMyIni:TIniFile;

begin

MyIni:=TIniFile.Create(´WIN.INI´);//调用的文件名

DelphiIni.WriteString(´Desktop´,´Wallpaper´,´c:a.bmp´);

end;

【delphi建立、读取、存贮INI文件的方法《三》】相关文章:

Delphi实现窗口文字淡入淡出渐变效果的方法

Delphi解析FTP地址的方法

Delphi远程连接Mysql的实现方法

Delphi实现图片滚动切换的完整实例代码

Delphi实现读取系统时间与日期完整实例

Delphi建立、读取、存贮INI文件的方法《一》

Delphi7中群发Email邮件的方法

Delphi控件ListView的属性及使用方法详解

Delphi实现判断网址是否存在及是否可以打开的方法

delphi制作wav文件的方法

精品推荐
分类导航