Browse Source

* Clear CurrentPath when closing registry.
* Delete test registry keys.

git-svn-id: trunk@22653 -

yury 12 years ago
parent
commit
9a3225f1af

+ 2 - 1
packages/fcl-registry/src/winreg.inc

@@ -260,7 +260,8 @@ begin
     else
       RegFlushKey(CurrentKey);
     fCurrentKey:=0;
-    end
+    end;
+  fCurrentPath:='';
 end;
 
 procedure TRegistry.CloseKey(key:HKEY);

+ 11 - 3
packages/fcl-registry/tests/testbasics.pp

@@ -42,7 +42,14 @@ var
   fn: string;
 {$endif}
 begin
-{$ifndef windows}
+{$ifdef windows}
+  with TRegistry.Create do
+    try
+      DeleteKey('FirstNode');
+    finally
+      Free;
+    end;
+{$else}
   FN:=includetrailingpathdelimiter(GetAppConfigDir(False))+'reg.xml';
   if FileExists(FN) then
     AssertTrue(DeleteFile(FN));
@@ -70,7 +77,7 @@ begin
   DeleteUserXmlFile;
   with TRegistry.Create do
     try
-      OpenKey('test', true);
+      OpenKey('FirstNode', true);
       WriteString('LAYOUT', '');
       CloseKey;
     finally
@@ -78,7 +85,7 @@ begin
     end;
   with TRegistry.Create do
     try
-      OpenKey('test', true);
+      OpenKey('FirstNode', true);
       WriteString('LAYOUT', '');
       CloseKey;
     finally
@@ -155,3 +162,4 @@ end;
 initialization
   RegisterTest(TTestBasics);
 end.
+

+ 10 - 0
packages/fcl-registry/tests/tregistry2.pp

@@ -35,8 +35,18 @@ begin
       TestFailed(4);
     if reg.CurrentPath <> STestRegPath + '\1' then
       TestFailed(5);
+    reg.CloseKey;
+    if reg.CurrentPath <> '' then
+      TestFailed(6);
   finally
     reg.Free;
+    with TRegistry.Create do
+      try
+        DeleteKey(STestRegPath + '\1');
+        DeleteKey(STestRegPath);
+      finally
+        Free;
+      end;
   end;
 end;