TRegistry - loadkey doesn't work
Hi!
I need to save/load a branch from the registry. I use following functions:
----------------------------------------------------------------------------
-------------------
function TTDM.RegWriteBranch(Key, FileName : String) : boolean;
Var
Reg: TRegistry;
begin
Reg := TRegistry.Create;
With Reg do
begin
RootKey := HKEY_LOCAL_MACHINE;
Result := SaveKey(Key, FileName);
end;
Reg.Free;
end;
----------------------------------------------------------------------------
-------------------
function TTDM.RegReadBranch(Key, FileName : String) : boolean;
Var
Reg: TRegistry;
begin
Reg := TRegistry.Create;
With Reg do
begin
RootKey := HKEY_LOCAL_MACHINE;
Result := LoadKey(Key, FileName);
end;
Reg.Free;
end;
----------------------------------------------------------------------------
-------------------
I am currently using win98.
Now, when I call the save function (with file parameter, 'C:\treg.dat'),
everything works O.K. I get a kind of binary file (not the usual
"export-format" from regedit.exe), and as far as I can tell all informations
and subbranches are in it, too.
But: I can't load it again! I have tried with and without fileextension, I
have tried to make the file a not-readonly and not-hidden (as default they
are both) and I have tried to call RestoreKey instead of Loadkey. Nothing
works. I just can't read the file back into the registry.
Are there any hidden tricks? Or should I just try convert to another
religion with a God more into programming and try a prayer?
Thanks in advance!
Poul Dige