Board index » delphi » tregistry.savekey: has anyone made it work?

tregistry.savekey: has anyone made it work?

I'm trying to get tregistry.SaveKey to do something useful (i.e. save hive
files).  The following test code always produces a "Failed" message, and
creates a file zero bytes in size.  Has anyone gotten tregistry.SaveKey to
work? I've tried all combinations of leading and trailing slashes in the
path to no avail. As usual, the Delphi docs aren't very helpful. (Delphi 6
on XP box).

If there are any secret tricks to using .LoadKey it'd be great to know about
those too :) 'cuz that's next!

Thanks,
-Matt

Quote

procedure test;
          var x                : tregistry;
              regpath,filepath : string;
          begin

          regpath:='\Software\Microsoft\Windows\CurrentVersion';
          filepath:='d:\tmp\test.bin';

          x:=tregistry.create;
          x.rootkey:=hkey_current_user;

          if x.SaveKey(regpath,filepath) then
             showmessage('Ok')
          else
             showmessage('Failed');

          x.CloseKey;
          end;
<<

 

Re:tregistry.savekey: has anyone made it work?


Quote
"Matt" <nos...@gruson.net> wrote in message

news:3ed6b274$1@newsgroups.borland.com...

Quote
> I'm trying to get tregistry.SaveKey to do something useful (i.e. save hive
> files). The following test code always produces a "Failed" message, and
> creates a file zero bytes in size.  Has anyone gotten tregistry.SaveKey to
> work? I've tried all combinations of leading and trailing slashes in the
> path to no avail. As usual, the Delphi docs aren't very helpful. (Delphi 6
> on XP box).

> If there are any secret tricks to using .LoadKey it'd be great to know
about
> those too :) 'cuz that's next!

> Thanks,
> -Matt

> procedure test;
>           var x                : tregistry;
>               regpath,filepath : string;
>           begin

>           regpath:='\Software\Microsoft\Windows\CurrentVersion';
>           filepath:='d:\tmp\test.bin';

>           x:=tregistry.create;
>           x.rootkey:=hkey_current_user;

>           if x.SaveKey(regpath,filepath) then
>              showmessage('Ok')
>           else
>              showmessage('Failed');

>           x.CloseKey;
>           end;

dunno, code above works for me as pasted

"Key is the key to save. FileName is the file into which to save the key
information. It must be the name of a new file that does not already exist.
On FAT file systems FileName cannot include an extension."

maybe the problem is somewhere in there?

actually it can exist and it can have an extension,at least for me
it seems to fail only if the file is already 'as it will be'

The only thing that continues to surprise me is that anything
works at all.

Re:tregistry.savekey: has anyone made it work?


Quote
"Terry Russell" <trochi...@bigpond.com> wrote in message

news:3ed6d40e@newsgroups.borland.com...
Quote
> "Matt" <nos...@gruson.net> wrote in message
> news:3ed6b274$1@newsgroups.borland.com...
> > I'm trying to get tregistry.SaveKey to do something useful (i.e. save
hive
> > files). The following test code always produces a "Failed" message, and
> > creates a file zero bytes in size.  Has anyone gotten tregistry.SaveKey
to
> > work? I've tried all combinations of leading and trailing slashes in the
> > path to no avail. As usual, the Delphi docs aren't very helpful. (Delphi
6
> > on XP box).

> > If there are any secret tricks to using .LoadKey it'd be great to know
> about
> > those too :) 'cuz that's next!

> > Thanks,
> > -Matt

> > procedure test;
> >           var x                : tregistry;
> >               regpath,filepath : string;
> >           begin

> >           regpath:='\Software\Microsoft\Windows\CurrentVersion';
> >           filepath:='d:\tmp\test.bin';

> >           x:=tregistry.create;
> >           x.rootkey:=hkey_current_user;

> >           if x.SaveKey(regpath,filepath) then
> >              showmessage('Ok')
> >           else
> >              showmessage('Failed');

> >           x.CloseKey;
> >           end;

> dunno, code above works for me as pasted

> "Key is the key to save. FileName is the file into which to save the key
> information. It must be the name of a new file that does not already
exist.
> On FAT file systems FileName cannot include an extension."

> maybe the problem is somewhere in there?

> actually it can exist and it can have an extension,at least for me
> it seems to fail only if the file is already 'as it will be'

> The only thing that continues to surprise me is that anything
> works at all.

I just ran around the house and tested it on numerous machines.  Apparently
it works on Win98, but not on NT/2000/XP.  Were you testing on a Win98
system?

Thanks,
Matt

Re:tregistry.savekey: has anyone made it work?


Quote
"Matt" <nos...@gruson.net> wrote in message

news:3ed76513$1@newsgroups.borland.com...

Quote
> > dunno, code above works for me as pasted

> > "Key is the key to save. FileName is the file into which to save the key
> > information. It must be the name of a new file that does not already
> exist.
> > On FAT file systems FileName cannot include an extension."

> > maybe the problem is somewhere in there?

> > actually it can exist and it can have an extension,at least for me
> > it seems to fail only if the file is already 'as it will be'

> > The only thing that continues to surprise me is that anything
> > works at all.

> I just ran around the house and tested it on numerous machines.
Apparently
> it works on Win98, but not on NT/2000/XP.  Were you testing on a Win98
> system?

should have said,w98 yes,  sorry

Not that it should matter.
Fat16 drive, with file extension , writing to an already existing file.
So it shouldn't work in , oh , so many ways ...

suggest: hope for the best,expect the worst

  check for file exists, delete it, write with no extension,rename

Other Threads