Changeset 122 for trunk/Packages/Common/URegistry.pas
- Timestamp:
- Jun 29, 2018, 11:44:07 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/URegistry.pas
r89 r122 9 9 10 10 type 11 TRegistryRoot = (rrKeyClassesRoot = HKEY($80000000), 12 rrKeyCurrentUser = HKEY($80000001), 13 rrKeyLocalMachine = HKEY($80000002), 14 rrKeyUsers = HKEY($80000003), 15 rrKeyPerformanceData = HKEY($80000004), 16 rrKeyCurrentConfig = HKEY($80000005), 17 rrKeyDynData = HKEY($80000006)); 11 TRegistryRoot = (rrKeyClassesRoot, rrKeyCurrentUser, rrKeyLocalMachine, 12 rrKeyUsers, rrKeyPerformanceData, rrKeyCurrentConfig, rrKeyDynData); 13 14 { TRegistryContext } 18 15 19 16 TRegistryContext = record 20 17 RootKey: HKEY; 21 18 Key: string; 19 class operator Equal(A, B: TRegistryContext): Boolean; 20 function Create(RootKey: TRegistryRoot; Key: string): TRegistryContext; overload; 21 function Create(RootKey: HKEY; Key: string): TRegistryContext; overload; 22 22 end; 23 23 … … 26 26 TRegistryEx = class(TRegistry) 27 27 private 28 function GetCurrentContext: TRegistryContext; 29 procedure SetCurrentContext(AValue: TRegistryContext); 28 30 public 29 31 function ReadBoolWithDefault(const Name: string; … … 35 37 function DeleteKeyRecursive(const Key: string): Boolean; 36 38 function OpenKey(const Key: string; CanCreate: Boolean): Boolean; 39 property CurrentContext: TRegistryContext read GetCurrentContext write SetCurrentContext; 37 40 end; 38 41 39 function RegContext(RootKey: HKEY; Key: string): TRegistryContext; 40 42 const 43 RegistryRootHKEY: array[TRegistryRoot] of HKEY = (HKEY_CLASSES_ROOT, 44 HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_PERFORMANCE_DATA, 45 HKEY_CURRENT_CONFIG, HKEY_DYN_DATA); 41 46 42 47 implementation 43 48 44 function RegContext(RootKey: HKEY; Key: string): TRegistryContext; 49 50 { TRegistryContext } 51 52 class operator TRegistryContext.Equal(A, B: TRegistryContext): Boolean; 53 begin 54 Result := (A.Key = B.Key) and (A.RootKey = B.RootKey); 55 end; 56 57 function TRegistryContext.Create(RootKey: TRegistryRoot; Key: string): TRegistryContext; 58 begin 59 Result.RootKey := RegistryRootHKEY[RootKey]; 60 Result.Key := Key; 61 end; 62 63 function TRegistryContext.Create(RootKey: HKEY; Key: string): TRegistryContext; 45 64 begin 46 65 Result.RootKey := RootKey; … … 106 125 end; 107 126 127 function TRegistryEx.GetCurrentContext: TRegistryContext; 128 begin 129 Result.Key := CurrentPath; 130 Result.RootKey := RootKey; 131 end; 132 133 procedure TRegistryEx.SetCurrentContext(AValue: TRegistryContext); 134 begin 135 RootKey := AValue.RootKey; 136 OpenKey(AValue.Key, True); 137 end; 138 108 139 function TRegistryEx.ReadBoolWithDefault(const Name: string; 109 140 DefaultValue: Boolean): Boolean;
Note:
See TracChangeset
for help on using the changeset viewer.