Board index » delphi » Unable to create hive file using TRegistry.SaveKey

Unable to create hive file using TRegistry.SaveKey

I'm trying to create a hive file of a key under HKEY_CURRENT_USER using the
SaveKey method of TRegistry. SaveKey continues to return FALSE so I ran the
code within registry.pas thru the de{*word*81}. The call to the WinAPI function
RegSaveKey returns 1314 - which I don't know the meaning of instead of
ERROR_SUCCESS. The hive file itself gets created but is empty when opened in

Having adminstrator privileges in both cases, I've gotten consistent results
with D3 & NT4.0 and with D5 & W2K. Any help would be greatly appreciated.



Re:Unable to create hive file using TRegistry.SaveKey

Hi again - I've done more research in old newsgroup threads using Google and
think I know the root of the problem. Quoting from Colin Wilson:

"Have a look at MSDN Article Q128731 HOWTO: How to Back Up the Windows NT
Registry.  It explains various things that aren't obvious.  In particular
you need to enable the SeBackupPrivilege (it's disabled by default, even
if your user account has the 'Backup Files And Directories' right)."

The article has a large block of C++ code (trying to read it gives me a
headache..sorry...) demonstrating how to set privileges. Since I'd rather
not reinvert the wheel, does anyone have a snippet of Delphi code (I fully
realize that WinAPI calls must be made), that enables SeBackupPrivilege
prior to the SaveKey call?

Extreme thanks in advance!

Other Threads