develooper Front page | perl.module-authors | Postings from February 2005

Win32::Tie Registry / Activestate Perl problem (?)

Thread Next
From:
Linda W
Date:
February 28, 2005 18:34
Subject:
Win32::Tie Registry / Activestate Perl problem (?)
Message ID:
4223D4B9.9040402@tlinx.org
I decided to temporarily give up on the cygwin version of
TieRegistry just to make some progress.

Very simplistic perl routine, that I can hard code
a starting key into the top of my tree,
then it goes through a fairly lame/brute-force
enumeration of all Members under the key -- recursing on
keynames and printing simplistic values for valuenames.

For keys/no values (included default), prints out
case where values aren't set, and prints out case where
value is set to null.

I had it enumerate my "Classes SubHive to completion.

However starting it on "CUser", it died farily quickly
under "Cuser\AppEvents\Schemes\Apps\ViaVoice\Pause Dictation US"

under that is a key called "st20ʰ".  The last character
displays a an empty square in the registry editory.  when I
cut and past the name in the registry editory into a vim file,
I ended up with the hex sequence:
73 74 32 30 CA B0 <--a 2 byte sequence.
 s  t  2  0
I have other occurances of the same name "st20ʰ under
say "Explorer\ActivatingDocument\st20ʰ -- and it's value is
correctly accessible.  But in enumerating the ViaVoice
event, I get that it cannot enumerate values for st20ʰ.

The last character displays a '?' if I print it out under
vim (with or without UTF8, as I thought it might be a UTF-8
sequence).

The complete listing program is:

#!/perl/bin/perl -w

use UTF8;

use Win32::TieRegistry 0.24 ;
select STDERR;$|=1;
select STDOUT;$|=1;

my ($col)=1;

$keyname='CUser\\AppEvents\\Schemes\\Apps';
print_key($Registry->{$keyname},$keyname,0);
   
sub print_key {
   
    my ($cur_key, $keyname, $level)=@_;

    if ($col) {
        print "\n";
        $col=0;
    }
    print "  " x $level; $col=2;
    print "$keyname\\";my $nospaces=1;
   
    foreach $member ($cur_key->MemberNames) {
        if ($member =~ m|^(.+)\\$|) {
            $keyname=$1;
            if ($col) {
                print "\n";
                $col=0;
            }
            $nospaces=0;
            print_key($cur_key->{"$keyname\\"}, "$keyname",$level+1);
        } elsif ($member =~ m|^\\(.*)$|) {
            $valuename=$1;
            $value=$cur_key->GetValue("$valuename");
            $value=(defined $value)?$value:"(value not set)";
            $value=(length($value))?$value:"(null)";
            if (!$nospaces) {print "  " x ($level+1); $col+=2;};
            $nospaces=0;
            print "$valuename => $value";
            if ($col) {
                print "\n";
                $col=0;
            }
        }
    }
}

-------
Program output:

CUser\AppEvents\Schemes\Apps\
  .Default\
    .Default\
      .Current\ => Audio\VoyTheme\STBeep1.wav
      .Default\ => C:\WINDOWS\Media\Windows XP\Windows XP Ding.wav
      Curren0\ => Audio\VoyTheme\STBeep1  <<Weird line
             ## note weird unprintable (zerospaced) character
             ## between '0' and '\'
      curren1\ => Audio\VoyTheme\STBeep1.wav
      current0肼\Can't call method "MemberNames" on an undefined value 
at ./test.pl line 60.   ## this one just fails

----------

    I can't see how this bug would occur as it works
correctly with other keys, but I can't help but imagine that
the unprintable character has something to do with problem.

I'm not even sure how unprintable characters would get into
a "saved" sound scheme....(it's not listed as one of the saved
sound schemes).

Any pointers with this would be appreciated....it's sorta my
first exploration into trying to play w/the registry
w/perl.  Can't figure out if it is bug in "TieRegistry" or
in Activestate Perl (5.8.6)

---------
This is perl, v5.8.6 built for MSWin32-x86-multi-thread
(with 3 registered patches, see perl -V for more detail)

Copyright 1987-2004, Larry Wall

Binary build 811 provided by ActiveState Corp. http://www.ActiveState.com
ActiveState is a division of Sophos.
Built Dec 13 2004 09:52:01




Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About