|
@@ -7,59 +7,127 @@ constructor TRegIniFile.Create(const FN: String);
|
|
begin
|
|
begin
|
|
inherited Create;
|
|
inherited Create;
|
|
fFileName := FN;
|
|
fFileName := FN;
|
|
|
|
+ if fFileName<>'' then
|
|
|
|
+ fPath := fFileName + '\'
|
|
|
|
+ else
|
|
|
|
+ fPath := '';
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TRegIniFile.DeleteKey(const Section, Ident: String);
|
|
procedure TRegIniFile.DeleteKey(const Section, Ident: String);
|
|
begin
|
|
begin
|
|
-
|
|
|
|
|
|
+ if not OpenKey(fPath+Section,true) then Exit;
|
|
|
|
+ try
|
|
|
|
+ DeleteValue(Ident);
|
|
|
|
+ finally
|
|
|
|
+ CloseKey;
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TRegIniFile.EraseSection(const Section: string);
|
|
procedure TRegIniFile.EraseSection(const Section: string);
|
|
begin
|
|
begin
|
|
-
|
|
|
|
|
|
+ inherited DeleteKey(fPath+Section);
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TRegIniFile.ReadSection(const Section: string; Strings: TStrings);
|
|
procedure TRegIniFile.ReadSection(const Section: string; Strings: TStrings);
|
|
begin
|
|
begin
|
|
-
|
|
|
|
|
|
+ if not OpenKey(fPath+Section,false) then Exit;
|
|
|
|
+ try
|
|
|
|
+ GetValueNames(Strings);
|
|
|
|
+ finally
|
|
|
|
+ CloseKey;
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TRegIniFile.ReadSections(Strings: TStrings);
|
|
procedure TRegIniFile.ReadSections(Strings: TStrings);
|
|
begin
|
|
begin
|
|
-
|
|
|
|
|
|
+ if not OpenKey(fFileName,false) then Exit;
|
|
|
|
+ try
|
|
|
|
+ GetKeyNames(Strings);
|
|
|
|
+ finally
|
|
|
|
+ CloseKey;
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TRegIniFile.ReadSectionValues(const Section: string; Strings: TStrings);
|
|
procedure TRegIniFile.ReadSectionValues(const Section: string; Strings: TStrings);
|
|
|
|
+var
|
|
|
|
+ ValList : TStringList;
|
|
|
|
+ V : String;
|
|
|
|
+ i : Integer;
|
|
begin
|
|
begin
|
|
-
|
|
|
|
|
|
+ if not OpenKey(fPath+Section,false) then Exit;
|
|
|
|
+ ValList := TStringList.Create;
|
|
|
|
+ try
|
|
|
|
+ GetValueNames(ValList);
|
|
|
|
+ for i:=0 to ValList.Count-1 do
|
|
|
|
+ begin
|
|
|
|
+ V := inherited ReadString(ValList.Strings[i]);
|
|
|
|
+ Strings.Add(ValList.Strings[i] + '=' + V);
|
|
|
|
+ end;
|
|
|
|
+ finally
|
|
|
|
+ ValList.Free;
|
|
|
|
+ CloseKey;
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TRegIniFile.WriteBool(const Section, Ident: string; Value: Boolean);
|
|
procedure TRegIniFile.WriteBool(const Section, Ident: string; Value: Boolean);
|
|
begin
|
|
begin
|
|
-
|
|
|
|
|
|
+ if not OpenKey(fPath+Section,true) then Exit;
|
|
|
|
+ try
|
|
|
|
+ inherited WriteBool(Ident,Value);
|
|
|
|
+ finally
|
|
|
|
+ CloseKey;
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TRegIniFile.WriteInteger(const Section, Ident: string; Value: LongInt);
|
|
procedure TRegIniFile.WriteInteger(const Section, Ident: string; Value: LongInt);
|
|
begin
|
|
begin
|
|
-
|
|
|
|
|
|
+ if not OpenKey(fPath+Section,true) then Exit;
|
|
|
|
+ try
|
|
|
|
+ inherited WriteInteger(Ident,Value);
|
|
|
|
+ finally
|
|
|
|
+ CloseKey;
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TRegIniFile.WriteString(const Section, Ident, Value: String);
|
|
procedure TRegIniFile.WriteString(const Section, Ident, Value: String);
|
|
begin
|
|
begin
|
|
-
|
|
|
|
|
|
+ if not OpenKey(fPath+Section,true) then Exit;
|
|
|
|
+ try
|
|
|
|
+ inherited WriteString(Ident,Value);
|
|
|
|
+ finally
|
|
|
|
+ CloseKey;
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
|
|
|
|
function TRegIniFile.ReadBool(const Section, Ident: string; Default: Boolean): Boolean;
|
|
function TRegIniFile.ReadBool(const Section, Ident: string; Default: Boolean): Boolean;
|
|
begin
|
|
begin
|
|
- Result := Default;
|
|
|
|
|
|
+ Result := Default;
|
|
|
|
+ if not OpenKey(fPath+Section,false) then Exit;
|
|
|
|
+ try
|
|
|
|
+ Result := inherited ReadBool(Ident);
|
|
|
|
+ finally
|
|
|
|
+ CloseKey;
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
|
|
|
|
function TRegIniFile.ReadInteger(const Section, Ident: string; Default: LongInt): LongInt;
|
|
function TRegIniFile.ReadInteger(const Section, Ident: string; Default: LongInt): LongInt;
|
|
begin
|
|
begin
|
|
Result := Default;
|
|
Result := Default;
|
|
|
|
+ if not OpenKey(fPath+Section,false) then Exit;
|
|
|
|
+ try
|
|
|
|
+ Result := inherited ReadInteger(Ident);
|
|
|
|
+ finally
|
|
|
|
+ CloseKey;
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
|
|
|
|
function TRegIniFile.ReadString(const Section, Ident, Default: String): String;
|
|
function TRegIniFile.ReadString(const Section, Ident, Default: String): String;
|
|
begin
|
|
begin
|
|
Result := Default;
|
|
Result := Default;
|
|
|
|
+ if not OpenKey(fPath+Section,false) then Exit;
|
|
|
|
+ try
|
|
|
|
+ Result := inherited ReadString(Ident);
|
|
|
|
+ finally
|
|
|
|
+ CloseKey;
|
|
|
|
+ end;
|
|
end;
|
|
end;
|