Commits

Anonymous committed 3cb747d

RootKey fix to make it more Object Inspector friendly.

Comments (0)

Files changed (1)

   end;
 
   TASConfigRegistryIniFile = class(TASCustomConfigRegistryIniFile)
+  private
+    function GetRootKeyName: string;
+    procedure SetRootKeyName(const Value: string);
+    function GetRootKeyNameStored: Boolean;
   published
     property ParentConfig;
     property Path;
-    property RootKey;
+    property RootKeyName: string read GetRootKeyName write SetRootKeyName stored GetRootKeyNameStored;
   end;
 
   TASConfigStore = class(TComponent)
 implementation
 
 uses
-  Registry;
+  Registry, StrUtils, Math;
+
+const
+  KeyNames: array[HKEY_CLASSES_ROOT..HKEY_DYN_DATA] of string = (
+    'HKEY_CLASSES_ROOT', 'HKEY_CURRENT_USER', 'HKEY_LOCAL_MACHINE',
+    'HKEY_USERS', 'HKEY_PERFORMANCE_DATA', 'HKEY_CURRENT_CONFIG', 'HKEY_DYN_DATA');
+
+  KeyValues: array[0 .. HKEY_DYN_DATA - HKEY_CLASSES_ROOT] of HKEY = (
+    HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE,
+    HKEY_USERS, HKEY_PERFORMANCE_DATA, HKEY_CURRENT_CONFIG, HKEY_DYN_DATA);
 
 procedure Register;
 begin
     (IniFile.IniFile as TRegistryIniFile).RegIniFile.RootKey := Value;
 end;
 
+{ TASConfigRegistryIniFile }
+
+function TASConfigRegistryIniFile.GetRootKeyName: string;
+begin
+  if (RootKey < HKEY_CLASSES_ROOT) or (RootKey > HKEY_DYN_DATA) then
+    RootKey := HKEY_CURRENT_USER;
+
+  Result := KeyNames[RootKey];
+end;
+
+function TASConfigRegistryIniFile.GetRootKeyNameStored: Boolean;
+begin
+  Result := RootKey <> HKEY_CURRENT_USER;
+end;
+
+procedure TASConfigRegistryIniFile.SetRootKeyName(const Value: string);
+var
+  I: Integer;
+begin
+  if Value <> '' then begin
+    I := IndexText(Value, KeyNames);
+    if InRange(I, Low(KeyValues), High(KeyValues)) then
+      RootKey := KeyValues[I];
+  end else
+    RootKey := HKEY_CURRENT_USER;
+end;
+
 end.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.