source: DockManagement/URegistry.pas

Last change on this file was 5, checked in by chronos, 12 years ago
File size: 1.6 KB
Line 
1unit URegistry;
2
3interface
4
5uses
6 Registry;
7
8type
9 TRegistryEx = class(TRegistry)
10 private
11 public
12 function ReadBoolWithDefault(const Name: string;
13 DefaultValue: Boolean): Boolean;
14 function ReadIntegerWithDefault(const Name: string; DefaultValue: Integer): Integer;
15 function ReadStringWithDefault(const Name: string; DefaultValue: string): string;
16 function ReadFloatWithDefault(const Name: string;
17 DefaultValue: Double): Double;
18 end;
19
20implementation
21
22{ TRegistryEx }
23
24function TRegistryEx.ReadIntegerWithDefault(const Name: string;
25 DefaultValue: Integer): Integer;
26begin
27 if ValueExists(Name) then Result := ReadInteger(Name)
28 else begin
29 WriteInteger(Name, DefaultValue);
30 Result := DefaultValue;
31 end;
32end;
33
34function TRegistryEx.ReadStringWithDefault(const Name: string;
35 DefaultValue: string): string;
36begin
37 if ValueExists(Name) then Result := ReadString(Name)
38 else begin
39 WriteString(Name, DefaultValue);
40 Result := DefaultValue;
41 end;
42end;
43
44function TRegistryEx.ReadFloatWithDefault(const Name: string;
45 DefaultValue: Double): Double;
46begin
47 if ValueExists(Name) then Result := ReadFloat(Name)
48 else begin
49 WriteFloat(Name, DefaultValue);
50 Result := DefaultValue;
51 end;
52end;
53
54function TRegistryEx.ReadBoolWithDefault(const Name: string;
55 DefaultValue: Boolean): Boolean;
56begin
57 if ValueExists(Name) then Result := ReadBool(Name)
58 else begin
59 WriteBool(Name, DefaultValue);
60 Result := DefaultValue;
61 end;
62end;
63
64end.
Note: See TracBrowser for help on using the repository browser.