就是下面的代码,只不过握把读的语句调用了多次的时候就出错了。
//向.INI文件写入字符串
WritePrivateProfileString(
'testfile', // []中标题的名字
'btn4', // 要写入“=”号前的字符串
'黄淮海ggggg', //要写入的数据
'd:/Program Files/Borland/Delphi5/Projects/testfile.ini' // 调用的文件名
);
//向.INI文件写入整数
WritePrivateProfileSection(
'windows', // []中标题的名字
'read=100', // 要写入的数据
'c:/forwin95/win.ini' // 调用的文件名
);
var
strResult
![Stick Out Tongue :P :P](https://cdn.jsdelivr.net/joypixels/assets/8.0/png/unicode/64/1f61b.png)
Char;
begin
strResult:='';//初始化很重要,否则会出错的
GetPrivateProfileString(
'testfile', // []中标题的名字
'btn1', // =号前的名字
'NIL', // 如果没有找到字符串时,返回的默认值
strResult, //存放取得字符
200, //取得字符的允许最大长度
'D:/Program Files/Borland/Delphi5/Projects/testfile.ini' // 调用的文件名
);
edit1.text:=strResult; //显示取得字符串
//从.INI文件中获取整数
//edit1.text:=inttostr(GetPrivateProfileInt(
//'testfile', // []中标题的名字
//'btn4', // =号前的名字
//0,// 如果没有找到整数时,返回的默认值
//'d:/Program Files/Borland/Delphi5/Projects/testfile.ini' // 调用的文件名
//));
end;