📄 inipas.pas
字号:
unit INIPAS ;
interface
uses INIFiles,SysUtils,Forms;
Function ReadINIStr(Const BASE_NAME,SUB_NAME,DEFAULT_RESULT:String):String;
Function ReadINIInt(Const BASE_NAME,SUB_NAME:String;DEFAULT_RESULT:Integer):Integer;
Function ReadINIBool(Const BASE_NAME,SUB_NAME:String;DEFAULT_RESULT:Boolean):Boolean;
Function WriteINIStr(Const BASE_NAME,SUB_NAME,DEFAULT_RESULT:String):Boolean;
Function WriteINIInt(Const BASE_NAME,SUB_NAME:String;DEFAULT_RESULT:Integer):Boolean;
implementation
Function ReadINIStr(Const BASE_NAME,SUB_NAME,DEFAULT_RESULT:String):String;
var INI:TINIFile;
Begin
INI:=TINIFile.Create(ExtractFilePath(Application.ExeName)+'CONFIG.INI');
With INI do
Begin
Result:=ReadString(BASE_NAME,SUB_NAME,DEFAULT_RESULT);
end;
INI.Free;
end;
Function ReadINIInt(Const BASE_NAME,SUB_NAME:String;DEFAULT_RESULT:Integer):Integer;
var INI:TINIFile;
Begin
INI:=TINIFile.Create(ExtractFilePath(Application.ExeName)+'CONFIG.INI');
With INI do
Begin
Result:=ReadInteger(BASE_NAME,SUB_NAME,DEFAULT_RESULT);
end;
INI.Free;
end;
Function ReadINIBool(Const BASE_NAME,SUB_NAME:String;DEFAULT_RESULT:Boolean):Boolean;
var INI:TINIFile;
Begin
INI:=TINIFile.Create(ExtractFilePath(Application.ExeName)+'CONFIG.INI');
With INI do
Begin
Result:=ReadBool(BASE_NAME,SUB_NAME,DEFAULT_RESULT);
end;
INI.Free;
end;
Function WriteINIStr(Const BASE_NAME,SUB_NAME,DEFAULT_RESULT:String):Boolean;
var INI:TINIFile;
Begin
Result:=True; Try
INI:=TINIFile.Create(ExtractFilePath(Application.ExeName)+'CONFIG.INI');
With INI do
Begin
WriteString(BASE_NAME,SUB_NAME,DEFAULT_RESULT);
end;
INI.Free;
Except Result:=False; end;
end;
Function WriteINIInt(Const BASE_NAME,SUB_NAME:String;DEFAULT_RESULT:Integer):Boolean;
var INI:TINIFile;
Begin
Result:=True; Try
INI:=TINIFile.Create(ExtractFilePath(Application.ExeName)+'CONFIG.INI');
With INI do
Begin
WriteInteger(BASE_NAME,SUB_NAME,DEFAULT_RESULT);
end;
INI.Free;
Except Result:=False; end;
end;
Function WriteINIBool(Const BASE_NAME,SUB_NAME:String;DEFAULT_RESULT:Boolean):Boolean;
var INI:TINIFile;
Begin
Result:=True; Try
INI:=TINIFile.Create(ExtractFilePath(Application.ExeName)+'CONFIG.INI');
With INI do
Begin
WriteBool(BASE_NAME,SUB_NAME,DEFAULT_RESULT);
end;
INI.Free;
Except Result:=False; end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -