Browse Source

* TRegistryIniFile: Fixed uninitialized Result in ValueExists(). Implemented SectionExists().

git-svn-id: trunk@48206 -
yury 4 years ago
parent
commit
2c196ee8a9
1 changed files with 13 additions and 7 deletions
  1. 13 7
      packages/fcl-registry/src/registry.pp

+ 13 - 7
packages/fcl-registry/src/registry.pp

@@ -266,6 +266,7 @@ type
     procedure DeleteKey(const Section, Name: String); override;
     procedure UpdateFile; override;
     function ValueExists(const Section, Ident: string): Boolean; override;
+    function SectionExists(const Section: string): Boolean; override;
     property RegIniFile: TRegIniFile read FRegIniFile;
   end{$ifdef XMLREG}deprecated 'Use TRegistry instead. Will be removed in 4.0'{$endif} platform; 
 
@@ -1125,13 +1126,18 @@ end;
 
 function TRegistryIniFile.ValueExists(const Section, Ident: string): Boolean;
 begin
-  with FRegInifile do
-    if OpenSection(Section) then
-      try
-        Result:=FRegInifile.ValueExists(Ident);
-      finally
-        CloseSection;
-      end;
+  Result:=FRegInifile.OpenSection(Section);
+  if Result then
+    try
+      Result:=FRegInifile.ValueExists(Ident);
+    finally
+      FRegInifile.CloseSection;
+    end;
+end;
+
+function TRegistryIniFile.SectionExists(const Section: string): Boolean;
+begin
+  Result:=FRegIniFile.KeyExists(Section);
 end;
 
 {$ifdef XMLREG}