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."

In reply to Gods, Graves and the Windows Registry by hsmyers

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.