home *** CD-ROM | disk | FTP | other *** search
- unit NTRegistry;
- {*******************************************************************************
-
- Author: HrbßΦ David
- Email: hrbac.david@usa.net, david@slovesa.hypermart.net
- Creation: 18th March 1999
- Version: 1.0
- Object: TNTRegistry
- Legal issues: Copyright ⌐ 1994-1999 by David HrbßΦ <hrbac.david@usa.net>
-
- 18th Mar 1999 1st release, TNTReg object
- 22nd Mar 1999 Changed to TNTRegistry
- *******************************************************************************}
-
- interface
-
- uses
- Windows, Registry;
-
- type
- TNTRegistry = class(TRegistry)
- private
- public
- function OpenKey(const Key: string; CanCreate: Boolean): Boolean;
- end;
-
- implementation
-
- function IsRelative(const Value: string): Boolean;
- begin
- Result := not ((Value <> '') and (Value[1] = '\'));
- end;
-
- function TNTRegistry.OpenKey(const Key: string; CanCreate: Boolean): Boolean;
- var
- TempKey: HKey;
- S: string;
- Disposition: Integer;
- Relative: Boolean;
- begin
- S := Key;
- Relative := IsRelative(S);
- if not Relative then Delete(S, 1, 1);
- TempKey := 0;
- if not CanCreate or (S = '') then
- begin
- Result := RegOpenKeyEx(GetBaseKey(Relative), PChar(S), 0,KEY_READ or KEY_WRITE, TempKey) = ERROR_SUCCESS;
- end else
- Result := RegCreateKeyEx(GetBaseKey(Relative), PChar(S), 0, nil,REG_OPTION_NON_VOLATILE, KEY_READ or KEY_WRITE, nil, TempKey, @Disposition) = ERROR_SUCCESS;
- if Result then
- begin
- if (CurrentKey <> 0) and Relative then
- S := CurrentPath + '\' + S;
- ChangeKey(TempKey, S);
- end;
- end;
-
- end.