Changeset 306 for trunk/Packages/Common/URegistry.pas
- Timestamp:
- Sep 5, 2020, 8:10:03 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/URegistry.pas
r192 r306 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 function Create(RootKey: TRegistryRoot; Key: string): TRegistryContext; static; overload; 20 class function Create(RootKey: HKEY; Key: string): TRegistryContext; static; overload; 19 21 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 … … 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; … … 55 58 end; 56 59 57 function TRegistryContext.Create(RootKey: TRegistryRoot; Key: string): TRegistryContext;60 class function TRegistryContext.Create(RootKey: TRegistryRoot; Key: string): TRegistryContext; 58 61 begin 59 62 Result.RootKey := RegistryRootHKEY[RootKey]; … … 61 64 end; 62 65 63 function TRegistryContext.Create(RootKey: HKEY; Key: string): TRegistryContext;66 class function TRegistryContext.Create(RootKey: HKEY; Key: string): TRegistryContext; 64 67 begin 65 68 Result.RootKey := RootKey; … … 85 88 else begin 86 89 WriteString(Name, DefaultValue); 90 Result := DefaultValue; 91 end; 92 end; 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); 87 100 Result := DefaultValue; 88 101 end; … … 120 133 begin 121 134 {$IFDEF Linux} 122 CloseKey;135 //CloseKey; 123 136 {$ENDIF} 124 137 Result := inherited OpenKey(Key, CanCreate); … … 137 150 end; 138 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); 164 end; 165 139 166 function TRegistryEx.ReadBoolWithDefault(const Name: string; 140 167 DefaultValue: Boolean): Boolean;
Note:
See TracChangeset
for help on using the changeset viewer.