markmm has asked for the wisdom of the Perl Monks concerning the following question:

I have code that open up a Win2000 registry, and can display a subtree of values and keys. I have a need to save off this subtree, and then be able to read it back when a new install is done. I am wondering if anyone has a sample program that is able to do this? When I try to do this a get a file created, but it is 0 length.

Replies are listed 'Best First'.
Re: TieRegistry save/load
by data64 (Chaplain) on Feb 28, 2002 at 18:19 UTC

    Use Storable

    Update:
    Untested code below:Ok, I went back and tested it.

    #!perl use Diagnostics; use strict; use warnings; use Win32::TieRegistry; use Data::Dumper; use Storable; my $key = $Registry->{ "HKEY_CLASSES_ROOT\\.pl\\" }; print Dumper( $key ); store $key, "foo.bar"; #write to a file my $read_key = retrieve( "foo.bar" ); #read it back print Dumper( $read_key ); $Registry->{"HKEY_CLASSES_ROOT\\.pl\\" } = $read_key;

    Update2:
    Added the last line to write the retrieved values to the registry.


    <cite>Just a tongue-tied, twisted, earth-bound misfit. -- Pink Floyd</cite>

      I tried the code, modified it a little bit to match my registry, Problem is that if I delete 1 of the subkeys, for example: HKEY_LOCAL_MACHINE\SOFTWARE\Canon\PowerShot\PSLL\601 out of the registry, and I run the retrieve, it does not create the entry, it seems to ignore the keys that are not in the tree.
      I tried the code, modified it a little bit to match my registry, Problem is that if I delete 1 of the subkeys, for example: HKEY_LOCAL_MACHINE\SOFTWARE\Canon\PowerShot\PSLL\601 out of the registry, and I run the retrieve, it does not create the entry, it seems to ignore the keys that are not in the tree. This is also true if I modify a subkey. Any suggestions?
Re: TieRegistry save/load
by Rex(Wrecks) (Curate) on Feb 28, 2002 at 17:55 UTC
    Without code it is really hard to say what is going wrong. However as an alternative, there are tons of tools that will dump the registry for you and then you can diff them for the result you want. system() ; ought to do the trick for you for those cases.

    Sorry, I'm not familiar enough with that module to give you a quick code block.

    "Nothing is sure but death and taxes" I say combine the two and its death to all taxes!