- 论坛徽章:
- 0
|
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');
list_key_value('SYSTEM');
sub list_key_value{
my ($Register)=@_[0];
my ($hkey,@key_list,$key);
my ($hNode,$Key,%values);
my ($RegType,$RegValue,$RegKey);
$HKEY_CURRENT_CONFIG->Open($Register,$hkey)||return;
print "$Register\n";
$hkey->GetValues(\%values);
foreach $value (keys(%values))
{
$RegType = $values{$value}->[1];
$RegValue = $values{$value}->[2];
$RegKey = $values{$value}->[0];
next if ($RegType eq '');
$RegKey = 'Default' if ($RegKey eq '');
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->GetKeys(\@key_list);
foreach $key (@key_list){list_key_value("$Register\\$key");}
$hkey->Close();
}
如上程序的方法能枚举注册表HKEY_LOCAL_MACHINE下的一个子键“SYSTEM”下所有的子键与值,如果要枚举HKEY_LOCAL_MACHINE下所有的子键和值应该怎么做呢?
我试过把“list_key_value('SYSTEM')”修改成list_key_value('') 或者list_key_value(' ')都没成功。
还请指点一二。 |
|