14
ERegistryException = class(Exception);
18
MaxSubKeyLen: Integer;
22
//FileTime: TFileTime;
25
TRegDataType = (rdUnknown, rdString, rdExpandString, rdInteger, rdBinary);
28
RegData: TRegDataType;
34
@abstract(Class to provide access to a registry.)
35
Introduced by Curtis White
36
Currently maintained by Curtis White
38
TRegistry = class(TObject)
44
//fCloseRootKey: Boolean;
46
procedure SetRootKey(Value: HKEY);
48
function GetBaseKey(Relative: Boolean): HKey;
49
function GetData(const Name: string; Buffer: Pointer;
50
BufSize: Integer; var RegData: TRegDataType): Integer;
51
function GetKey(const Key: string): HKEY;
53
procedure ChangeKey(Value: HKey; const Path: string);
54
procedure PutData(const Name: string; Buffer: Pointer;
55
BufSize: Integer; RegData: TRegDataType);
56
procedure SetCurrentKey(Value: HKEY);
59
destructor Destroy; override;
61
function CreateKey(const Key: string): Boolean;
62
function DeleteKey(const Key: string): Boolean;
63
function DeleteValue(const Name: string): Boolean;
64
function GetDataInfo(const ValueName: string; var Value: TRegDataInfo): Boolean;
65
function GetDataSize(const ValueName: string): Integer;
66
function GetDataType(const ValueName: string): TRegDataType;
67
function GetKeyInfo(var Value: TRegKeyInfo): Boolean;
68
function HasSubKeys: Boolean;
69
function KeyExists(const Key: string): Boolean;
70
function LoadKey(const Key, FileName: string): Boolean;
71
function OpenKey(const Key: string; CanCreate: Boolean): Boolean;
72
//function ReadCurrency(const Name: string): Currency;
73
function ReadBinaryData(const Name: string; var Buffer; BufSize: Integer): Integer;
74
function ReadBool(const Name: string): Boolean;
75
function ReadDate(const Name: string): TDateTime;
76
function ReadDateTime(const Name: string): TDateTime;
77
function ReadFloat(const Name: string): Double;
78
function ReadInteger(const Name: string): Integer;
79
function ReadString(const Name: string): string;
80
function ReadTime(const Name: string): TDateTime;
81
function RegistryConnect(const UNCName: string): Boolean;
82
function ReplaceKey(const Key, FileName, BackUpFileName: string): Boolean;
83
function RestoreKey(const Key, FileName: string): Boolean;
84
function SaveKey(const Key, FileName: string): Boolean;
85
function UnLoadKey(const Key: string): Boolean;
86
function ValueExists(const Name: string): Boolean;
89
procedure GetKeyNames(Strings: TStrings);
90
procedure GetValueNames(Strings: TStrings);
91
procedure MoveKey(const OldName, NewName: string; Delete: Boolean);
92
procedure RenameValue(const OldName, NewName: string);
93
//procedure WriteCurrency(const Name: string; Value: Currency);
94
procedure WriteBinaryData(const Name: string; var Buffer; BufSize: Integer);
95
procedure WriteBool(const Name: string; Value: Boolean);
96
procedure WriteDate(const Name: string; Value: TDateTime);
97
procedure WriteDateTime(const Name: string; Value: TDateTime);
98
procedure WriteFloat(const Name: string; Value: Double);
99
procedure WriteInteger(const Name: string; Value: Integer);
100
procedure WriteString(const Name, Value: string);
101
procedure WriteExpandString(const Name, Value: string);
102
procedure WriteTime(const Name: string; Value: TDateTime);
104
property CurrentKey: HKEY read fCurrentKey;
105
property CurrentPath: string read fCurrentPath;
106
property LazyWrite: Boolean read fLazyWrite write fLazyWrite;
107
property RootKey: HKEY read fRootKey write SetRootKey;
112
@abstract(Class to provide access to a registry in an Ini file manner.)
113
Introduced by Curtis White
114
Currently maintained by Curtis White
116
TRegIniFile = class(TRegistry)
120
constructor Create(const FN: string);
122
function ReadString(const Section, Ident, Default: string): string;
123
function ReadInteger(const Section, Ident: string;
124
Default: Longint): Longint;
125
function ReadBool(const Section, Ident: string; Default: Boolean): Boolean;
127
procedure WriteString(const Section, Ident, Value: String);
128
procedure WriteInteger(const Section, Ident: string; Value: Longint);
129
procedure WriteBool(const Section, Ident: string; Value: Boolean);
130
procedure ReadSection(const Section: string; Strings: TStrings);
131
procedure ReadSections(Strings: TStrings);
132
procedure ReadSectionValues(const Section: string; Strings: TStrings);
133
procedure EraseSection(const Section: string);
134
procedure DeleteKey(const Section, Ident: String);
136
property FileName: String read fFileName;
142
{******************************************************************************
144
******************************************************************************}
145
{------------------------------------------------------------------------------
146
Method: TRegistry.Create
150
Constructor for the class.
151
------------------------------------------------------------------------------}
152
constructor TRegistry.Create;
157
{------------------------------------------------------------------------------
158
Method: TRegistry.Destroy
162
Destructor for the class.
163
------------------------------------------------------------------------------}
164
destructor TRegistry.Destroy;
169
{------------------------------------------------------------------------------
170
Function: TRegistry.CreateKey
171
Params: Key: String key to create
172
Returns: Boolean containing result of the create. True if it succeeded.
174
Create a registry key.
175
------------------------------------------------------------------------------}
176
function TRegistry.CreateKey(const Key: String): Boolean;
181
{------------------------------------------------------------------------------
182
Function: TRegistry.DeleteKey
183
Params: Key: String key to create
184
Returns: Boolean containing result of the delete. True if it succeeded.
186
Delete a registry key.
187
------------------------------------------------------------------------------}
188
function TRegistry.DeleteKey(const Key: String): Boolean;
193
{------------------------------------------------------------------------------
194
Function: TRegistry.DeleteValue
195
Params: Name: Name of key of which to delete its value
196
Returns: Boolean containing result of the function. True if it succeeded.
198
Delete the value for a registry key.
199
------------------------------------------------------------------------------}
200
function TRegistry.DeleteValue(const Name: String): Boolean;
205
{------------------------------------------------------------------------------
206
Function: TRegistry.GetBaseKey
207
Params: Relative: Is the key relative or absolute. True if relative.
208
Returns: HKey containing the base key.
211
------------------------------------------------------------------------------}
212
function TRegistry.GetBaseKey(Relative: Boolean): HKey;
214
Result := CurrentKey;
217
{------------------------------------------------------------------------------
218
Function: TRegistry.GetData
219
Params: Name: name of the key
223
Returns: Integer containing output from the function.
225
Gets data from the registry.
226
------------------------------------------------------------------------------}
227
function TRegistry.GetData(const Name: String; Buffer: Pointer;
228
BufSize: Integer; var RegData: TRegDataType): Integer;
233
{------------------------------------------------------------------------------
234
Function: TRegistry.GetDataInfo
235
Params: ValueName: name of the value to get info on
237
Returns: Boolean containing result of the function. True if it succeeded.
239
Get info on the data value.
240
------------------------------------------------------------------------------}
241
function TRegistry.GetDataInfo(const ValueName: String; var Value: TRegDataInfo): Boolean;
246
{------------------------------------------------------------------------------
247
Function: TRegistry.GetDataSize
248
Params: ValueName: name of the value to get info on
249
Returns: Integer containing the size of the value.
251
Get the size of the data value.
252
------------------------------------------------------------------------------}
253
function TRegistry.GetDataSize(const ValueName: String): Integer;
258
{------------------------------------------------------------------------------
259
Function: TRegistry.GetDataType
260
Params: ValueName: name of the value to get info on
261
Returns: TRegDataType containing type of the value.
263
Get the type of the data value.
264
------------------------------------------------------------------------------}
265
function TRegistry.GetDataType(const ValueName: string): TRegDataType;
270
{------------------------------------------------------------------------------
271
Function: TRegistry.GetKey
272
Params: Key: key to get
273
Returns: HKey containing the key.
275
Get a key from the registry.
276
------------------------------------------------------------------------------}
277
function TRegistry.GetKey(const Key: String): HKEY;
282
{------------------------------------------------------------------------------
283
Function: TRegistry.GetKeyInfo
284
Params: Value: value of info to get key info on
285
Returns: Boolean containing result of the function. True if it succeeded.
287
Get the info of a key.
288
------------------------------------------------------------------------------}
289
function TRegistry.GetKeyInfo(var Value: TRegKeyInfo): Boolean;
294
{------------------------------------------------------------------------------
295
Function: TRegistry.HasSubKeys
297
Returns: Boolean containing result of the function. True if there are sub
300
See if the key has sub keys.
301
------------------------------------------------------------------------------}
302
function TRegistry.HasSubKeys: Boolean;
307
{------------------------------------------------------------------------------
308
Function: TRegistry.KeyExists
309
Params: Key: the name of the key
310
Returns: Boolean containing result of the function. True if the key exists.
312
Check to see if a key exists.
313
------------------------------------------------------------------------------}
314
function TRegistry.KeyExists(const Key: string): Boolean;
319
{------------------------------------------------------------------------------
320
Function: TRegistry.LoadKey
321
Params: Key: the name of the key
322
FileName: file containing the key to load
323
Returns: Boolean containing result of the function. True if it succeeded.
325
Load a key from a file.
326
------------------------------------------------------------------------------}
327
function TRegistry.LoadKey(const Key, FileName: string): Boolean;
332
{------------------------------------------------------------------------------
333
Function: TRegistry.OpenKey
334
Params: Key: the name of the key
335
CanCreate: create the key if it does not exist. True to create
336
Returns: Boolean containing result of the function. True if it succeeded.
338
Open a key and optionally create it if is does not exist.
339
------------------------------------------------------------------------------}
340
function TRegistry.OpenKey(const Key: string; CanCreate: Boolean): Boolean;
350
{------------------------------------------------------------------------------
351
Function: TRegistry.ReadBinaryData
352
Params: AOwner: the owner of the class
353
Returns: String containing output from the function.
355
Description of the function for the class.
356
------------------------------------------------------------------------------}
357
function TRegistry.ReadBinaryData(const Name: string; var Buffer; BufSize: Integer): Integer;
362
{------------------------------------------------------------------------------
363
Function: TRegistry.ReadBool
364
Params: AOwner: the owner of the class
365
Returns: String containing output from the function.
367
Description of the function for the class.
368
------------------------------------------------------------------------------}
369
function TRegistry.ReadBool(const Name: string): Boolean;
374
{------------------------------------------------------------------------------
375
Function: TRegistry.ReadCurrency
376
Params: AOwner: the owner of the class
377
Returns: String containing output from the function.
379
Description of the function for the class.
380
------------------------------------------------------------------------------}
381
{function TRegistry.ReadCurrency(const Name: string): Currency;
386
{------------------------------------------------------------------------------
387
Function: TRegistry.ReadDate
388
Params: AOwner: the owner of the class
389
Returns: String containing output from the function.
391
Description of the function for the class.
392
------------------------------------------------------------------------------}
393
function TRegistry.ReadDate(const Name: string): TDateTime;
398
{------------------------------------------------------------------------------
399
Function: TRegistry.ReadDateTime
400
Params: AOwner: the owner of the class
401
Returns: String containing output from the function.
403
Description of the function for the class.
404
------------------------------------------------------------------------------}
405
function TRegistry.ReadDateTime(const Name: string): TDateTime;
410
{------------------------------------------------------------------------------
411
Function: TRegistry.ReadFloat
412
Params: AOwner: the owner of the class
413
Returns: String containing output from the function.
415
Description of the function for the class.
416
------------------------------------------------------------------------------}
417
function TRegistry.ReadFloat(const Name: string): Double;
422
{------------------------------------------------------------------------------
423
Function: TRegistry.ReadInteger
424
Params: AOwner: the owner of the class
425
Returns: String containing output from the function.
427
Description of the function for the class.
428
------------------------------------------------------------------------------}
429
function TRegistry.ReadInteger(const Name: string): Integer;
434
{------------------------------------------------------------------------------
435
Function: TRegistry.ReadString
436
Params: AOwner: the owner of the class
437
Returns: String containing output from the function.
439
Description of the function for the class.
440
------------------------------------------------------------------------------}
441
function TRegistry.ReadString(const Name: string): string;
446
{------------------------------------------------------------------------------
447
Function: TRegistry.ReadTime
448
Params: AOwner: the owner of the class
449
Returns: String containing output from the function.
451
Description of the function for the class.
452
------------------------------------------------------------------------------}
453
function TRegistry.ReadTime(const Name: string): TDateTime;
458
{------------------------------------------------------------------------------
459
Function: TRegistry.RegistryConnect
460
Params: AOwner: the owner of the class
461
Returns: String containing output from the function.
463
Description of the function for the class.
464
------------------------------------------------------------------------------}
465
function TRegistry.RegistryConnect(const UNCName: string): Boolean;
470
{------------------------------------------------------------------------------
471
Function: TRegistry.ReplaceKey
472
Params: AOwner: the owner of the class
473
Returns: String containing output from the function.
475
Description of the function for the class.
476
------------------------------------------------------------------------------}
477
function TRegistry.ReplaceKey(const Key, FileName, BackUpFileName: string): Boolean;
482
{------------------------------------------------------------------------------
483
Function: TRegistry.RestoreKey
484
Params: AOwner: the owner of the class
485
Returns: String containing output from the function.
487
Description of the function for the class.
488
------------------------------------------------------------------------------}
489
function TRegistry.RestoreKey(const Key, FileName: string): Boolean;
494
{------------------------------------------------------------------------------
495
Function: TRegistry.SaveKey
496
Params: AOwner: the owner of the class
497
Returns: String containing output from the function.
499
Description of the function for the class.
500
------------------------------------------------------------------------------}
501
function TRegistry.SaveKey(const Key, FileName: string): Boolean;
506
{------------------------------------------------------------------------------
507
Function: TRegistry.UnLoadKey
508
Params: AOwner: the owner of the class
509
Returns: String containing output from the function.
511
Description of the function for the class.
512
------------------------------------------------------------------------------}
513
function TRegistry.UnLoadKey(const Key: string): Boolean;
518
{------------------------------------------------------------------------------
519
Function: TRegistry.ValueExists
520
Params: AOwner: the owner of the class
521
Returns: String containing output from the function.
523
Description of the function for the class.
524
------------------------------------------------------------------------------}
525
function TRegistry.ValueExists(const Name: string): Boolean;
536
{------------------------------------------------------------------------------
537
Method: TRegistry.CloseKey
538
Params: AOwner: the owner of the class
541
Description of the procedure for the class.
542
------------------------------------------------------------------------------}
543
procedure TRegistry.CloseKey;
548
{------------------------------------------------------------------------------
549
Method: TRegistry.ChangeKey
550
Params: AOwner: the owner of the class
553
Description of the procedure for the class.
554
------------------------------------------------------------------------------}
555
procedure TRegistry.ChangeKey(Value: HKey; const Path: String);
560
{------------------------------------------------------------------------------
561
Method: TRegistry.GetKeyName
562
Params: AOwner: the owner of the class
565
Description of the procedure for the class.
566
------------------------------------------------------------------------------}
567
procedure TRegistry.GetKeyNames(Strings: TStrings);
572
{------------------------------------------------------------------------------
573
Method: TRegistry.GetValueNames
574
Params: AOwner: the owner of the class
577
Description of the procedure for the class.
578
------------------------------------------------------------------------------}
579
procedure TRegistry.GetValueNames(Strings: TStrings);
584
{------------------------------------------------------------------------------
585
Method: TRegistry.MoveKey
586
Params: AOwner: the owner of the class
589
Description of the procedure for the class.
590
------------------------------------------------------------------------------}
591
procedure TRegistry.MoveKey(const OldName, NewName: string; Delete: Boolean);
596
{------------------------------------------------------------------------------
597
Method: TRegistry.PutData
598
Params: AOwner: the owner of the class
601
Description of the procedure for the class.
602
------------------------------------------------------------------------------}
603
procedure TRegistry.PutData(const Name: string; Buffer: Pointer;
604
BufSize: Integer; RegData: TRegDataType);
609
{------------------------------------------------------------------------------
610
Method: TRegistry.RenameValue
611
Params: AOwner: the owner of the class
614
Description of the procedure for the class.
615
------------------------------------------------------------------------------}
616
procedure TRegistry.RenameValue(const OldName, NewName: string);
621
{------------------------------------------------------------------------------
622
Method: TRegistry.SetCurrentKey
623
Params: AOwner: the owner of the class
626
Description of the procedure for the class.
627
------------------------------------------------------------------------------}
628
procedure TRegistry.SetCurrentKey(Value: HKEY);
630
fCurrentKey := Value;
633
{------------------------------------------------------------------------------
634
Method: TRegistry.SetRootKey
635
Params: AOwner: the owner of the class
638
Description of the procedure for the class.
639
------------------------------------------------------------------------------}
640
procedure TRegistry.SetRootKey(Value: HKEY);
645
{------------------------------------------------------------------------------
646
Method: TRegistry.WriteBinaryData
647
Params: AOwner: the owner of the class
650
Description of the procedure for the class.
651
------------------------------------------------------------------------------}
652
procedure TRegistry.WriteBinaryData(const Name: string; var Buffer; BufSize: Integer);
657
{------------------------------------------------------------------------------
658
Method: TRegistry.WriteBool
659
Params: AOwner: the owner of the class
662
Description of the procedure for the class.
663
------------------------------------------------------------------------------}
664
procedure TRegistry.WriteBool(const Name: string; Value: Boolean);
669
{------------------------------------------------------------------------------
670
Method: TRegistry.WriteCurrency
671
Params: AOwner: the owner of the class
674
Description of the procedure for the class.
675
------------------------------------------------------------------------------}
676
{procedure TRegistry.WriteCurrency(const Name: string; Value: Currency);
681
{------------------------------------------------------------------------------
682
Method: TRegistry.WriteDate
683
Params: AOwner: the owner of the class
686
Description of the procedure for the class.
687
------------------------------------------------------------------------------}
688
procedure TRegistry.WriteDate(const Name: string; Value: TDateTime);
693
{------------------------------------------------------------------------------
694
Method: TRegistry.WriteDateTime
695
Params: AOwner: the owner of the class
698
Description of the procedure for the class.
699
------------------------------------------------------------------------------}
700
procedure TRegistry.WriteDateTime(const Name: string; Value: TDateTime);
705
{------------------------------------------------------------------------------
706
Method: TRegistry.WriteExpandString
707
Params: AOwner: the owner of the class
710
Description of the procedure for the class.
711
------------------------------------------------------------------------------}
712
procedure TRegistry.WriteExpandString(const Name, Value: string);
717
{------------------------------------------------------------------------------
718
Method: TRegistry.WriteFloat
719
Params: AOwner: the owner of the class
722
Description of the procedure for the class.
723
------------------------------------------------------------------------------}
724
procedure TRegistry.WriteFloat(const Name: string; Value: Double);
729
{------------------------------------------------------------------------------
730
Method: TRegistry.WriteInteger
731
Params: AOwner: the owner of the class
734
Description of the procedure for the class.
735
------------------------------------------------------------------------------}
736
procedure TRegistry.WriteInteger(const Name: string; Value: Integer);
741
{------------------------------------------------------------------------------
742
Method: TRegistry.WriteString
743
Params: AOwner: the owner of the class
746
Description of the procedure for the class.
747
------------------------------------------------------------------------------}
748
procedure TRegistry.WriteString(const Name, Value: string);
753
{------------------------------------------------------------------------------
754
Method: TRegistry.WriteTime
755
Params: AOwner: the owner of the class
758
Description of the procedure for the class.
759
------------------------------------------------------------------------------}
760
procedure TRegistry.WriteTime(const Name: string; Value: TDateTime);
766
{******************************************************************************
768
******************************************************************************}
769
{------------------------------------------------------------------------------
770
Method: TRegIniFile.Create
774
Constructor for the class.
775
------------------------------------------------------------------------------}
776
constructor TRegIniFile.Create(const FN: String);
782
{------------------------------------------------------------------------------
783
Method: TRegIniFile.MyMethod
784
Params: AOwner: the owner of the class
787
Description of the procedure for the class.
788
------------------------------------------------------------------------------}
789
procedure TRegIniFile.DeleteKey(const Section, Ident: String);
794
{------------------------------------------------------------------------------
795
Method: TRegIniFile.MyMethod
796
Params: AOwner: the owner of the class
799
Description of the procedure for the class.
800
------------------------------------------------------------------------------}
801
procedure TRegIniFile.EraseSection(const Section: string);
806
{------------------------------------------------------------------------------
807
Method: TRegIniFile.MyMethod
808
Params: AOwner: the owner of the class
811
Description of the procedure for the class.
812
------------------------------------------------------------------------------}
813
procedure TRegIniFile.ReadSection(const Section: string; Strings: TStrings);
818
{------------------------------------------------------------------------------
819
Method: TRegIniFile.MyMethod
820
Params: AOwner: the owner of the class
823
Description of the procedure for the class.
824
------------------------------------------------------------------------------}
825
procedure TRegIniFile.ReadSections(Strings: TStrings);
830
{------------------------------------------------------------------------------
831
Method: TRegIniFile.MyMethod
832
Params: AOwner: the owner of the class
835
Description of the procedure for the class.
836
------------------------------------------------------------------------------}
837
procedure TRegIniFile.ReadSectionValues(const Section: string; Strings: TStrings);
842
{------------------------------------------------------------------------------
843
Method: TRegIniFile.MyMethod
844
Params: AOwner: the owner of the class
847
Description of the procedure for the class.
848
------------------------------------------------------------------------------}
849
procedure TRegIniFile.WriteBool(const Section, Ident: string; Value: Boolean);
854
{------------------------------------------------------------------------------
855
Method: TRegIniFile.MyMethod
856
Params: AOwner: the owner of the class
859
Description of the procedure for the class.
860
------------------------------------------------------------------------------}
861
procedure TRegIniFile.WriteInteger(const Section, Ident: string; Value: LongInt);
866
{------------------------------------------------------------------------------
867
Method: TRegIniFile.MyMethod
868
Params: AOwner: the owner of the class
871
Description of the procedure for the class.
872
------------------------------------------------------------------------------}
873
procedure TRegIniFile.WriteString(const Section, Ident, Value: String);
880
{------------------------------------------------------------------------------
881
Function: TRegIniFile.MyFunction
882
Params: AOwner: the owner of the class
883
Returns: String containing output from the function.
885
Description of the function for the class.
886
------------------------------------------------------------------------------}
887
function TRegIniFile.ReadBool(const Section, Ident: string; Default: Boolean): Boolean;
892
{------------------------------------------------------------------------------
893
Function: TRegIniFile.MyFunction
894
Params: AOwner: the owner of the class
895
Returns: String containing output from the function.
897
Description of the function for the class.
898
------------------------------------------------------------------------------}
899
function TRegIniFile.ReadInteger(const Section, Ident: string; Default: LongInt): LongInt;
904
{------------------------------------------------------------------------------
905
Function: TRegIniFile.MyFunction
906
Params: AOwner: the owner of the class
907
Returns: String containing output from the function.
909
Description of the function for the class.
910
------------------------------------------------------------------------------}
911
function TRegIniFile.ReadString(const Section, Ident, Default: String): String;
920
$Log: registry.pp,v $
921
Revision 1.1 2000/07/13 06:31:31 michael
924
Revision 1.1 2000/06/02 19:48:48 peter
925
* empty registry unit inserted