If someone else has this set up (NT Server, BCB4 with service packs), Please
try this:
Be sure to #include <vcl\registry.hpp>
Then create a new form and put a button on it that runs this code:
(NOTE: C:\X must not exist prior to running this function, so delete it
each time your run this)
TRegistry * Reg = new TRegistry;
Reg->RootKey = HKEY_LOCAL_MACHINE;
// savekey is supposed to return bool, and true is good.
if ( Reg->SaveKey("SOFTWARE\\Borland", "C:\\X" ))
{
// it worked
ShowMessage("It worked.");}
else
{
// it didn't work
ShowMessage("It failed.");
}
delete Reg;
return;
Please let me know what you find out.
Thanks - Greg
Jodi? Are you there?
I have NT WkStn 4, SP3 with BCB3, patch #1. Tried your example and got the
same results as you: SaveKey returned false and an empty file was created.
Just out of curiousity, I tried it with Delphi 3.02 on the same machine with
the same results. Sounds like a VCL bug to me!
Jef
Are you logged on as an administrator? From what I've read on these
newsgroups, TRegistry doesn't generally work with WinNT with normal
user access because it tries to open the registry with KEY_ALL_ACCESS
access, which WinNT only allows administrators to do.
On Tue, 9 Mar 1999 20:57:37 -0500, "gap" <g...@nospam.org> wrote:
:I've tried everything, and I must conclude that there is a bug in
:TRegistry->SaveKey. It Always returns "False", GetLastError says 0, file is
:created, but it is empty. According to analysis of another newsgroup
:lurker, it works under win95 and BCB1. I have Win NT4 Server with SP4, BCB
:3 with patch #1, and it doesn't work.
:
:If someone else has this set up (NT Server, BCB4 with service packs), Please
:try this:
:
:Be sure to #include <vcl\registry.hpp>
:
It looks like the guys at Borland didn't test this function on NT - only
win95 or 98, where it works! It really does not work under Winnt. This is
because the VCL code for TRegistry->SaveKey does not set the temporary
security access flag called "SE_BACKUP_NAME" that is required for NT. Win95
and Win98 ignore this privelege. I found the fix by reading about the MS
implementation of RegSaveKey function. I searched the MS Newsgroups, and
found a hit, where it referred me to the following link:
http://mvps.org/win32/security/privs.html
This is a 2kb cpp file that can be compiled and run (in a dos box) under NT.
It will enumerate the available privs and print them out, and set one called
"SE_TCB_NAME". I changed the example code to set one for SE_BACKUP_NAME,
and tried the RegSaveKey function, and it worked!
These priveleges are above and beyond Administrator rights. I am admin, and
couldn't do it until I set that bit. This bit only is in effect for the
current process. When the process terminates, the bit is turned off (I
think!).
I Hope this helps others to use the functions, and I hope this helps Borland
fix TRegistry!
I probably could have done these MS API calls before the
Tregistry->SaveKey VCL function, had I known about it. But, the help file
for TRegistry->SaveKey implies that "it does it all". It opens the key,
dumps the registry to a file, then closes the key. It should also do what
it says to do in the example at http://mvps.org/win32/security/privs.html !.
Thanks for your input -
Jody - are you watching?
Greg Pearce
Eric Rossing wrote in message <36e7e124...@forums.inprise.com>...