Changeset 131 for trunk/Packages/Common/URegistry.pas
- Timestamp:
- Mar 18, 2022, 1:37:03 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/URegistry.pas
r123 r131 1 1 unit URegistry; 2 2 3 {$MODE Delphi}3 {$MODE delphi} 4 4 5 5 interface … … 17 17 RootKey: HKEY; 18 18 Key: string; 19 class operator Equal(A, B: TRegistryContext): Boolean;20 19 class function Create(RootKey: TRegistryRoot; Key: string): TRegistryContext; static; overload; 21 20 class function Create(RootKey: HKEY; Key: string): TRegistryContext; static; overload; 21 class operator Equal(A, B: TRegistryContext): Boolean; 22 22 end; 23 23 … … 29 29 procedure SetCurrentContext(AValue: TRegistryContext); 30 30 public 31 function ReadChar(const Name: string): Char; 32 procedure WriteChar(const Name: string; Value: Char); 31 33 function ReadBoolWithDefault(const Name: string; 32 34 DefaultValue: Boolean): Boolean; 33 35 function ReadIntegerWithDefault(const Name: string; DefaultValue: Integer): Integer; 34 36 function ReadStringWithDefault(const Name: string; DefaultValue: string): string; 37 function ReadCharWithDefault(const Name: string; DefaultValue: Char): Char; 35 38 function ReadFloatWithDefault(const Name: string; 36 39 DefaultValue: Double): Double; … … 89 92 end; 90 93 94 function TRegistryEx.ReadCharWithDefault(const Name: string; DefaultValue: Char 95 ): Char; 96 begin 97 if ValueExists(Name) then Result := ReadChar(Name) 98 else begin 99 WriteChar(Name, DefaultValue); 100 Result := DefaultValue; 101 end; 102 end; 103 91 104 function TRegistryEx.ReadFloatWithDefault(const Name: string; 92 105 DefaultValue: Double): Double; … … 119 132 function TRegistryEx.OpenKey(const Key: string; CanCreate: Boolean): Boolean; 120 133 begin 121 {$IFDEF Linux}122 CloseKey;134 {$IFDEF UNIX} 135 //CloseKey; 123 136 {$ENDIF} 124 137 Result := inherited OpenKey(Key, CanCreate); … … 127 140 function TRegistryEx.GetCurrentContext: TRegistryContext; 128 141 begin 129 Result.Key := CurrentPath;142 Result.Key := String(CurrentPath); 130 143 Result.RootKey := RootKey; 131 144 end; … … 135 148 RootKey := AValue.RootKey; 136 149 OpenKey(AValue.Key, True); 150 end; 151 152 function TRegistryEx.ReadChar(const Name: string): Char; 153 var 154 S: string; 155 begin 156 S := ReadString(Name); 157 if Length(S) > 0 then Result := S[1] 158 else Result := #0; 159 end; 160 161 procedure TRegistryEx.WriteChar(const Name: string; Value: Char); 162 begin 163 WriteString(Name, Value); 137 164 end; 138 165
Note:
See TracChangeset
for help on using the changeset viewer.