wandrey
asked on
TRegistry.SaveKey
Delphi 5, TRegistry.SaveKey
function SaveKey(const Key, FileName: String): Boolean; does not work anyway.
Someone knows the usage to make it work?
Regards
Wandrey
function SaveKey(const Key, FileName: String): Boolean; does not work anyway.
Someone knows the usage to make it work?
Regards
Wandrey
ASKER
Ok, thats all simple beginning - I have wrote many tools with TRegistry, access local and remote hosts, read, write and change values - all of that was no problem. But the SaveKey does not function at all - not in the manner the online help suggests nor in any other imaginable possibility.
Background: I want to write a hole key with all of its subkeys and values to a diskfile for later campares to avoid the enumaration through the hole keys and values. The prog. must run on NT 4 SP6 in the admin security context (so there are no restrictions).
Background: I want to write a hole key with all of its subkeys and values to a diskfile for later campares to avoid the enumaration through the hole keys and values. The prog. must run on NT 4 SP6 in the admin security context (so there are no restrictions).
Hello,
I've looked in the Borland community
http://community.borland.com/article/0,1410,10348,00.html
looks like there's an error in D5 TRegistry.
Good luck, Martin
I've looked in the Borland community
http://community.borland.com/article/0,1410,10348,00.html
looks like there's an error in D5 TRegistry.
Good luck, Martin
ASKER
Hello,
thanks for all your efforts, I have search and found these and other articles also. But there seem to be some people out there, who has solve this problem, or might say dont have this problem.(i.e. in here:qid=10128124 is a question around this topic).
regards
Willy
thanks for all your efforts, I have search and found these and other articles also. But there seem to be some people out there, who has solve this problem, or might say dont have this problem.(i.e. in here:qid=10128124 is a question around this topic).
regards
Willy
ASKER
Concrete:
Called from Button1Click()->
>>>>>>>>>>>>>>>>>>>>>>>>
procedure TForm1.scanregpath;
var i:integer;
sl:tstringlist;
begin
cu := TRegistry.Create;
cu.RootKey := HKEY_LOCAL_MACHINE;
try
if cu.savekey('\software\McAf ee\VirusSc an','c:\te mp\rkey') then
showmessage('Written...')
else showmessage('Fail');
finally
cu.Free;
end;
end;
<<<<<<<<<<<<<<<<<<<<<<<<<< <<
This returns "Fail". The file in C:\TEMP was created but empty.
Called from Button1Click()->
>>>>>>>>>>>>>>>>>>>>>>>>
procedure TForm1.scanregpath;
var i:integer;
sl:tstringlist;
begin
cu := TRegistry.Create;
cu.RootKey := HKEY_LOCAL_MACHINE;
try
if cu.savekey('\software\McAf
showmessage('Written...')
else showmessage('Fail');
finally
cu.Free;
end;
end;
<<<<<<<<<<<<<<<<<<<<<<<<<<
This returns "Fail". The file in C:\TEMP was created but empty.
Hi,
i just tested this and it seems to work ok ,see how it goes for you :
implementation
{$R *.DFM}
uses registry;
procedure TForm1.Button1Click(Sender : TObject);
var
reg : tregistry;
begin
Reg := TRegistry.Create;
Reg.RootKey:=HKEY_LOCAL_MA CHINE; {OR HKEY_USERS }
if not fileexists('c:\myreg.reg') then
try
if Reg.SaveKey('\Software\Bor land\Delph i', 'c:\myreg.reg') then
ShowMessage( 'Saved' )
else
ShowMessage( 'Error Saving' )
finally
Reg.Free;
end
else showmessage('File already exists');
end;
Regards Barry
i just tested this and it seems to work ok ,see how it goes for you :
implementation
{$R *.DFM}
uses registry;
procedure TForm1.Button1Click(Sender
var
reg : tregistry;
begin
Reg := TRegistry.Create;
Reg.RootKey:=HKEY_LOCAL_MA
if not fileexists('c:\myreg.reg')
try
if Reg.SaveKey('\Software\Bor
ShowMessage( 'Saved' )
else
ShowMessage( 'Error Saving' )
finally
Reg.Free;
end
else showmessage('File already exists');
end;
Regards Barry
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, this was very good!
Regards
Willy
Regards
Willy
I don't know what you did before and what functions you have used before. So I begin with the first step:
var
Reg : TRegistry;
begin
Reg := TRegistry.Create();
Reg.RootKey := HKEY_LOCAL_MACHINE; <- Maybe that's what you forgot
Good luck,
Martin