home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1996 August / VPR9608A.BIN / del20try / install / data.z / REGISTRY.INT < prev    next >
Text File  |  1996-05-08  |  5KB  |  114 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Delphi Visual Component Library                 }
  5. {                                                       }
  6. {       Copyright (c) 1996 Borland International        }
  7. {                                                       }
  8. {*******************************************************}
  9.  
  10. unit Registry;
  11.  
  12. {$R-}
  13.  
  14. interface
  15.  
  16. uses Windows, Classes, SysUtils;
  17.  
  18. type
  19.   ERegistryException = class(Exception);
  20.  
  21.   TRegKeyInfo = record
  22.     NumSubKeys: Integer;
  23.     MaxSubKeyLen: Integer;
  24.     NumValues: Integer;
  25.     MaxValueLen: Integer;
  26.     MaxDataLen: Integer;
  27.     FileTime: TFileTime;
  28.   end;
  29.  
  30.   TRegDataType = (rdUnknown, rdString, rdExpandString, rdInteger, rdBinary);
  31.  
  32.   TRegDataInfo = record
  33.     RegData: TRegDataType;
  34.     DataSize: Integer;
  35.   end;
  36.  
  37.   TRegistry = class(TObject)
  38.   protected
  39.     procedure ChangeKey(Value: HKey; const Path: string);
  40.     function GetBaseKey(Relative: Boolean): HKey;
  41.     function GetData(const Name: string; Buffer: Pointer;
  42.       BufSize: Integer; var RegData: TRegDataType): Integer;
  43.     function GetKey(const Key: string): HKEY;
  44.     procedure PutData(const Name: string; Buffer: Pointer; BufSize: Integer; RegData: TRegDataType);
  45.     procedure SetCurrentKey(Value: HKEY);
  46.   public
  47.     constructor Create;
  48.     destructor Destroy; override;
  49.     procedure CloseKey;
  50.     function CreateKey(const Key: string): Boolean;
  51.     function DeleteKey(const Key: string): Boolean;
  52.     function DeleteValue(const Name: string): Boolean;
  53.     function GetDataInfo(const ValueName: string; var Value: TRegDataInfo): Boolean;
  54.     function GetDataSize(const ValueName: string): Integer;
  55.     function GetDataType(const ValueName: string): TRegDataType;
  56.     function GetKeyInfo(var Value: TRegKeyInfo): Boolean;
  57.     procedure GetKeyNames(Strings: TStrings);
  58.     procedure GetValueNames(Strings: TStrings);
  59.     function HasSubKeys: Boolean;
  60.     function KeyExists(const Key: string): Boolean;
  61.     function LoadKey(const Key, FileName: string): Boolean;
  62.     procedure MoveKey(const OldName, NewName: string; Delete: Boolean);
  63.     function OpenKey(const Key: string; CanCreate: Boolean): Boolean;
  64.     function ReadCurrency(const Name: string): Currency;
  65.     function ReadBinaryData(const Name: string; var Buffer; BufSize: Integer): Integer;
  66.     function ReadBool(const Name: string): Boolean;
  67.     function ReadDate(const Name: string): TDateTime;
  68.     function ReadDateTime(const Name: string): TDateTime;
  69.     function ReadFloat(const Name: string): Double;
  70.     function ReadInteger(const Name: string): Integer;
  71.     function ReadString(const Name: string): string;
  72.     function ReadTime(const Name: string): TDateTime;
  73.     function RegistryConnect(const UNCName: string): Boolean;
  74.     procedure RenameValue(const OldName, NewName: string);
  75.     function ReplaceKey(const Key, FileName, BackUpFileName: string): Boolean;
  76.     function RestoreKey(const Key, FileName: string): Boolean;
  77.     function SaveKey(const Key, FileName: string): Boolean;
  78.     function UnLoadKey(const Key: string): Boolean;
  79.     function ValueExists(const Name: string): Boolean;
  80.     procedure WriteCurrency(const Name: string; Value: Currency);
  81.     procedure WriteBinaryData(const Name: string; var Buffer; BufSize: Integer);
  82.     procedure WriteBool(const Name: string; Value: Boolean);
  83.     procedure WriteDate(const Name: string; Value: TDateTime);
  84.     procedure WriteDateTime(const Name: string; Value: TDateTime);
  85.     procedure WriteFloat(const Name: string; Value: Double);
  86.     procedure WriteInteger(const Name: string; Value: Integer);
  87.     procedure WriteString(const Name, Value: string);
  88.     procedure WriteTime(const Name: string; Value: TDateTime);
  89.     property CurrentKey: HKEY;
  90.     property CurrentPath: string;
  91.     property LazyWrite: Boolean;
  92.     property RootKey: HKEY;
  93.   end;
  94.  
  95.   TRegIniFile = class(TRegistry)
  96.   public
  97.     constructor Create(const FileName: string);
  98.     function ReadString(const Section, Ident, Default: string): string;
  99.     procedure WriteString(const Section, Ident, Value: String);
  100.     function ReadInteger(const Section, Ident: string;
  101.       Default: Longint): Longint;
  102.     procedure WriteInteger(const Section, Ident: string; Value: Longint);
  103.     function ReadBool(const Section, Ident: string; Default: Boolean): Boolean;
  104.     procedure WriteBool(const Section, Ident: string; Value: Boolean);
  105.     procedure ReadSection(const Section: string; Strings: TStrings);
  106.     procedure ReadSections(Strings: TStrings);
  107.     procedure ReadSectionValues(const Section: string; Strings: TStrings);
  108.     procedure EraseSection(const Section: string);
  109.     procedure DeleteKey(const Section, Ident: String);
  110.     property FileName: string;
  111.   end;
  112.  
  113. implementation
  114.