programming-examples/perl/Win32/Registry Key Deletion.pl
2019-11-15 12:59:38 +01:00

25 lines
714 B
Perl

use Win32::Registry;
$key = "SOFTWARE\\yourValue";
$HKEY_LOCAL_MACHINE->Open($key, $keyList);
print "Under HKEY_LOCAL_MACHINE\n\tyourValue\n";
$keyList->GetKeys(\@subKeys);
$numberOfSubKeys = @subKeys;
print "\tThere are $numberOfSubKeys keys\n";
foreach $subKey (@subKeys){
print "\t\t$subKey\n";
}
$key = "newKey";
print "\nDeleting the $key Key\n";
if (!$keyList->DeleteKey($key)){
print "Failed to delete $key\n";
}
print "Under HKEY_LOCAL_MACHINE\n\tyourValue\n";
$keyList->GetKeys(\@newSubKeys);
$numberOfSubKeys = @newSubKeys;
print "\tThere are now $numberOfSubKeys key\n";
foreach $subKey (@newSubKeys){
print "\t\t$subKey\n";
}
$keyList->Close();