develooper Front page | perl.beginners | Postings from January 2002

[PBML] RE: Extract a value of a key into a hash

From:
Jorge Goncalvez
Date:
January 10, 2002 02:48
Subject:
[PBML] RE: Extract a value of a key into a hash
Message ID:
200201101048.LAA08748@cabs40.col.bsf.alcatel.fr



Hi, I have this code:
#!/usr/local/bin/perl -w

use Win32::Registry;
my %RegType = (
			0 => 'REG_0',
			1 => 'REG_SZ',
			2 => 'REG_EXPAND_SZ',
			3 => 'REG_BINARY',
			4 => 'REG_DWORD',
			5 => 'REG_DWORD_BIG_ENDIAN',
			6 => 'REG_LINK',
			7 => 'REG_MULTI_SZ',
			8 => 'REG_RESOURCE_LIST',
			9 => 'REG_FULL_RESOURCE_DESCRIPTION',
			10 => 'REG_RESSOURCE_REQUIREMENT_MAP');

my $Register = "Software\\MICROSOFT\\Windows\\CurrentVersion\\explorer\\Shell 
Folders";
my $RegType, $RegValue, $RegKey, $value;
my %values;

$HKEY_LOCAL_MACHINE->Open($Register,$hkey)|| die $!;
#$hkey="Common Desktop";

$hkey->GetValues(\%values);

foreach $value (keys(%values))
	{
	$RegType 	= $values{$value}->[1];
	$RegValue 	= $values{$value}->[2];
	$RegKey 	= $values{$value}->[0];
	next if ($RegType eq '');  #do not print default value if not assigned
	$RegKey 	= 'Common Desktop' if ($RegKey eq '');	#name the 
default key
	print "$RegKey";
	print " ($RegType{$RegType}) : ";

	SWITCH:
		{
		if ($RegType == 4)
			{printf "Ox%1x \n", unpack("L",$RegValue); last SWITCH; 
}
		if ($RegType == 5)
			{printf "Ox%1x", unpack("N",$RegValue); last SWITCH; }
 		if ($RegType < 8 )
			{printf "$RegValue\n"; last SWITCH; }
		print "\n";
		}
	}
$hkey->Close();


What i wanted is to print the value of the hash %values for the name "Common 
Desktop" only;
Now it prints all thereis in th epath 

%values Hash (Name, Type, Value) for each value 

Thanks






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