一般INI文件
function GetIniString(Section, Key, FilePath: String): String;
var
Default, ReturnValue: array [0..255] of char;
begin
GetPrivateProfileString(PChar(Section), PChar(Key), Default, ReturnValue, 255, PChar(FilePath));
Result := ReturnValue;
end;
procedure SetIniString(Section, Key, Value, FilePath: String);
begin
WritePrivateProfileString(PChar(Section), PChar(Key), PChar(Value), PChar(FilePath));
end;
与应用程序同名的INI文件
function AppGetIniString(Section, Key: String): String;
var
FilePath: String;
begin
FilePath := ChangeFileExt(Application.ExeName, '.log');
Result := GetIniString(Section, Key, FilePath);
end;
procedure AppSetIniString(Section, Key, Value: String);
var
FilePath: String;
begin
FilePath := ChangeFileExt(Application.ExeName, '.log');
SetIniString(Section, Key, Value, FilePath);
end;