[EMAIL PROTECTED] wrote:
>
> Hey, gurus....
>
> I'm looking at a need to change the value of one byte in a REG_BINARY
> registry value. It will need to be switched back and forth between the
> values 0x0d and 0x09. Also, it's not guaranteed to be a multiple of
> eight bytes in length, so pack and unpack won't be usable--especially
> because pack "ignores" any bytes that aren't part of an eight.
>
> Any suggestions?
You should be able to use pack just fine on them:
use strict;
use warnings;
use Win32::TieRegistry;
use Win32API::Registry qw(:REG_);
my $key = 'HKEY_LOCAL_MACHINE\SOFTWARE\TestKey';
my $val = $Registry->{"$key\\Binary"} or die "$! ($^E)"; # get binary subkey
my @bytes = unpack 'C*', $val; # unpack into byte array
printf "%02X ", $_ foreach @bytes;
print "\n";
$bytes[0] = 0xFF; # modify a couple of bytes
$bytes[1] = 0xFE;
$val = pack 'C*', @bytes; # repack
$Registry->{"$key\\Binary"} = [$val, REG_BINARY]; # store back
$val = $Registry->{"$key\\Binary"} or die "$! ($^E)"; # check it
@bytes = unpack 'C*', $val;
printf "%02X ", $_ foreach @bytes;
print "\n";
__END__
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs