请各位大侠告知在Delphi 5.0中如何实现。谢谢!
4 个解决方案
#1
TIniFile
#2
//删除键值
procedure MyIni_DeleteKey(MySection,MyIdent:string);
begin
Myini:=TIniFile.Create(IniFilename);
Myini.DeleteKey(MySection,MyIdent);
Myini.Free;
end;
//删除段
procedure MyIni_EraseSection(MySection:string);
begin
Myini:=TIniFile.Create(IniFilename);
Myini.EraseSection(MySection);
Myini.Free;
end;
//读取Bool值
function MyIni_ReadBool(MySection,MyIdent:string;
MyBool:Boolean):Boolean;
begin
Myini:=TIniFile.Create(IniFilename);
Result:=Myini.ReadBool(MySection,MyIdent,MyBool);
Myini.Free;
end;
//读取Integer值
function MyIni_ReadInteger(MySection,MyIdent:string;
MyInteger:Integer):Integer;
begin
Myini:=TIniFile.Create(IniFilename);
Result:=Myini.ReadInteger(MySection,MyIdent,MyInteger);
Myini.Free;
end;
//读取字符串值
function MyIni_ReadString(MySection,MyIdent:string;
MyString:String):Pchar;
begin
Myini:=TIniFile.Create(IniFilename);
Result:=Pchar(Myini.ReadString(MySection,MyIdent,MyString));
Myini.Free;
end;
//写入Bool值
procedure MyIni_WriteBool(MySection,MyIdent:string;
MyBool:Boolean);
begin
Myini:=TIniFile.Create(IniFilename);
Myini.WriteBool(MySection,MyIdent,MyBool);
Myini.Free;
end;
//写入Integer值
procedure MyIni_WriteInteger(MySection,MyIdent:string;
MyInteger:Integer);
begin
Myini:=TIniFile.Create(IniFilename);
Myini.WriteInteger(MySection,MyIdent,MyInteger);
Myini.Free;
end;
//写入String值
procedure MyIni_WriteString(MySection,MyIdent:string;
MyString:String);
begin
Myini:=TIniFile.Create(IniFilename);
Myini.WriteString(MySection,MyIdent,MyString);
Myini.Free;
end;
procedure MyIni_DeleteKey(MySection,MyIdent:string);
begin
Myini:=TIniFile.Create(IniFilename);
Myini.DeleteKey(MySection,MyIdent);
Myini.Free;
end;
//删除段
procedure MyIni_EraseSection(MySection:string);
begin
Myini:=TIniFile.Create(IniFilename);
Myini.EraseSection(MySection);
Myini.Free;
end;
//读取Bool值
function MyIni_ReadBool(MySection,MyIdent:string;
MyBool:Boolean):Boolean;
begin
Myini:=TIniFile.Create(IniFilename);
Result:=Myini.ReadBool(MySection,MyIdent,MyBool);
Myini.Free;
end;
//读取Integer值
function MyIni_ReadInteger(MySection,MyIdent:string;
MyInteger:Integer):Integer;
begin
Myini:=TIniFile.Create(IniFilename);
Result:=Myini.ReadInteger(MySection,MyIdent,MyInteger);
Myini.Free;
end;
//读取字符串值
function MyIni_ReadString(MySection,MyIdent:string;
MyString:String):Pchar;
begin
Myini:=TIniFile.Create(IniFilename);
Result:=Pchar(Myini.ReadString(MySection,MyIdent,MyString));
Myini.Free;
end;
//写入Bool值
procedure MyIni_WriteBool(MySection,MyIdent:string;
MyBool:Boolean);
begin
Myini:=TIniFile.Create(IniFilename);
Myini.WriteBool(MySection,MyIdent,MyBool);
Myini.Free;
end;
//写入Integer值
procedure MyIni_WriteInteger(MySection,MyIdent:string;
MyInteger:Integer);
begin
Myini:=TIniFile.Create(IniFilename);
Myini.WriteInteger(MySection,MyIdent,MyInteger);
Myini.Free;
end;
//写入String值
procedure MyIni_WriteString(MySection,MyIdent:string;
MyString:String);
begin
Myini:=TIniFile.Create(IniFilename);
Myini.WriteString(MySection,MyIdent,MyString);
Myini.Free;
end;
#3
uses 中加入 Inifiles
procedure ....
var
inifile:Tinifile;
filename:string;
begin
//建立与aa.ini的联系
inifile := Tinifile.create('aa.ini');
//从PROGRAM节读File的设置信息
filename := inifile.readstring('PROGRAM','FILE','');
//释放
INIFILE.free;
ShowMessage(filename);
end;
procedure ....
var
inifile:Tinifile;
filename:string;
begin
//建立与aa.ini的联系
inifile := Tinifile.create('aa.ini');
//从PROGRAM节读File的设置信息
filename := inifile.readstring('PROGRAM','FILE','');
//释放
INIFILE.free;
ShowMessage(filename);
end;
#4
uses
IniFiles;
IniFiles;
#1
TIniFile
#2
//删除键值
procedure MyIni_DeleteKey(MySection,MyIdent:string);
begin
Myini:=TIniFile.Create(IniFilename);
Myini.DeleteKey(MySection,MyIdent);
Myini.Free;
end;
//删除段
procedure MyIni_EraseSection(MySection:string);
begin
Myini:=TIniFile.Create(IniFilename);
Myini.EraseSection(MySection);
Myini.Free;
end;
//读取Bool值
function MyIni_ReadBool(MySection,MyIdent:string;
MyBool:Boolean):Boolean;
begin
Myini:=TIniFile.Create(IniFilename);
Result:=Myini.ReadBool(MySection,MyIdent,MyBool);
Myini.Free;
end;
//读取Integer值
function MyIni_ReadInteger(MySection,MyIdent:string;
MyInteger:Integer):Integer;
begin
Myini:=TIniFile.Create(IniFilename);
Result:=Myini.ReadInteger(MySection,MyIdent,MyInteger);
Myini.Free;
end;
//读取字符串值
function MyIni_ReadString(MySection,MyIdent:string;
MyString:String):Pchar;
begin
Myini:=TIniFile.Create(IniFilename);
Result:=Pchar(Myini.ReadString(MySection,MyIdent,MyString));
Myini.Free;
end;
//写入Bool值
procedure MyIni_WriteBool(MySection,MyIdent:string;
MyBool:Boolean);
begin
Myini:=TIniFile.Create(IniFilename);
Myini.WriteBool(MySection,MyIdent,MyBool);
Myini.Free;
end;
//写入Integer值
procedure MyIni_WriteInteger(MySection,MyIdent:string;
MyInteger:Integer);
begin
Myini:=TIniFile.Create(IniFilename);
Myini.WriteInteger(MySection,MyIdent,MyInteger);
Myini.Free;
end;
//写入String值
procedure MyIni_WriteString(MySection,MyIdent:string;
MyString:String);
begin
Myini:=TIniFile.Create(IniFilename);
Myini.WriteString(MySection,MyIdent,MyString);
Myini.Free;
end;
procedure MyIni_DeleteKey(MySection,MyIdent:string);
begin
Myini:=TIniFile.Create(IniFilename);
Myini.DeleteKey(MySection,MyIdent);
Myini.Free;
end;
//删除段
procedure MyIni_EraseSection(MySection:string);
begin
Myini:=TIniFile.Create(IniFilename);
Myini.EraseSection(MySection);
Myini.Free;
end;
//读取Bool值
function MyIni_ReadBool(MySection,MyIdent:string;
MyBool:Boolean):Boolean;
begin
Myini:=TIniFile.Create(IniFilename);
Result:=Myini.ReadBool(MySection,MyIdent,MyBool);
Myini.Free;
end;
//读取Integer值
function MyIni_ReadInteger(MySection,MyIdent:string;
MyInteger:Integer):Integer;
begin
Myini:=TIniFile.Create(IniFilename);
Result:=Myini.ReadInteger(MySection,MyIdent,MyInteger);
Myini.Free;
end;
//读取字符串值
function MyIni_ReadString(MySection,MyIdent:string;
MyString:String):Pchar;
begin
Myini:=TIniFile.Create(IniFilename);
Result:=Pchar(Myini.ReadString(MySection,MyIdent,MyString));
Myini.Free;
end;
//写入Bool值
procedure MyIni_WriteBool(MySection,MyIdent:string;
MyBool:Boolean);
begin
Myini:=TIniFile.Create(IniFilename);
Myini.WriteBool(MySection,MyIdent,MyBool);
Myini.Free;
end;
//写入Integer值
procedure MyIni_WriteInteger(MySection,MyIdent:string;
MyInteger:Integer);
begin
Myini:=TIniFile.Create(IniFilename);
Myini.WriteInteger(MySection,MyIdent,MyInteger);
Myini.Free;
end;
//写入String值
procedure MyIni_WriteString(MySection,MyIdent:string;
MyString:String);
begin
Myini:=TIniFile.Create(IniFilename);
Myini.WriteString(MySection,MyIdent,MyString);
Myini.Free;
end;
#3
uses 中加入 Inifiles
procedure ....
var
inifile:Tinifile;
filename:string;
begin
//建立与aa.ini的联系
inifile := Tinifile.create('aa.ini');
//从PROGRAM节读File的设置信息
filename := inifile.readstring('PROGRAM','FILE','');
//释放
INIFILE.free;
ShowMessage(filename);
end;
procedure ....
var
inifile:Tinifile;
filename:string;
begin
//建立与aa.ini的联系
inifile := Tinifile.create('aa.ini');
//从PROGRAM节读File的设置信息
filename := inifile.readstring('PROGRAM','FILE','');
//释放
INIFILE.free;
ShowMessage(filename);
end;
#4
uses
IniFiles;
IniFiles;