As anyone who has worked with perl data structures knows, there are times when you have to take something apart and lay it all out in order to understand what is what and where is where! This is particularly true with the Windows registry. Surprisingly the obsolete Win32::Registry can be the basis of still quite useful code. Here as a quick and dirty example is a sort of Data::Dumper for registry branches:
#!/perl/bin/perl # # RegPeek.pl -- Q&D dump of registry information. use strict; use warnings; use diagnostics; use Win32::Registry; for ("HARDWARE\\DEVICEMAP\\Scsi","SYSTEM\\CurrentControlSet\\Enum\\IDE +") { print "$_\n"; ShowSubKeys($HKEY_LOCAL_MACHINE,$_,1); } sub ShowSubKeys { my ($h,$s,$level) = @_; my $hkey; my @subkeys; my %values; $h->Open($s,$hkey); $hkey->GetKeys(\@subkeys); if (@subkeys) { for (@subkeys) { print "", ' ' x ($level * 2),"$_\n"; ShowSubKeys($h,"$s\\$_",$level + 1); } } $hkey->GetValues(\%values); for (keys %values) { my ($name,$type,$value) = @{$values{$_}}; print "", ' ' x ($level * 2),"\"$name\" = \"$value\"\n" if $ty +pe eq '1'; } }
Update: Patched bug in GetValues portion of code.

--hsm

"Never try to teach a pig to sing...it wastes your time and it annoys the pig."

Replies are listed 'Best First'.
Re: Gods, Graves and the Windows Registry
by Mr. Muskrat (Canon) on Jun 27, 2003 at 13:19 UTC
    Cool idea but I don't see why you didn't just use the non-obsolete Win32::TieRegistry written by none other than tye.
      Stubborn I say, just plain old fashion stubborn...also since these map directly onto the win32 API and since I'm writing the 'real' code in C++, it kind of seemed the thing to do. Other than that, no good reason!

      --hsm

      "Never try to teach a pig to sing...it wastes your time and it annoys the pig."