Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Greetings fellow monks,

I'm not sure if my problem is with my misunderstanding of how the registry works, or my somehow failing to use the Win32::TieRegistry module correctly.  My intent is to delete the key 'HKEY_CLASSES_ROOT/Folder/shell/xyzzy_1' from the Windows XP registry on my laptop computer.

First of all, here's my code:

#!/usr/bin/perl -w # # Attempt to delete 'HKEY_CLASSES_ROOT/Folder/shell/xyzzy_1' from the # Windows Registry, using Win32::TieRegistry. ## ############# # Libraries # ############# use strict; use warnings; use Data::Dumper; use Win32::TieRegistry( Delimiter => '/' ); ################ # Main Program # ################ # Step 1 -- assign variables my $label = "xyzzy_1"; my $key = 'HKEY_CLASSES_ROOT/Folder/shell'; my $h_shell = $Registry->{$key}; (defined $h_shell) or die "Unable to find registry key '$key'\n"; # Step 2 -- Display all keys for HKEY_CLASSES_ROOT/Folder/shell print "[Values for '$key']\n"; my $idx = 0; foreach my $key (keys %$h_shell) { printf " %3d. %s\n", ++$idx, $key; } print "\n\n"; # Step 3 -- Validate that the label 'xyzzy_1' was found if (!exists($h_shell->{$label})) { die "No such label for '$key' => '$label'\n"; } # Step 4 -- Delete 'xyzzy_1' from 'HKEY_CLASSES_ROOT/Folder/shell' print "Deleting label '$label' ...\n"; my $result = delete($h_shell->{$label}); print "Result of delete: '$result'\n";

Prior to running the program, I created a registry key "HKEY_CLASSES_ROOT/Folder/shell/xyzzy_1", which along with the existing keys for the parent key look like this according to regedit (note my use of '###' for the folder icon):

[+]-### FName.Factoid [+]-### FName.Factoid.2 [+]-### fndfile {+]-### Folder | |--### DefaultIcon | [-]-### shell | | [+]--### explore | | [+]--### open | | |---### xyzzy_1 | [+]-### shellex [+]-### fonfile [+]-### FormHost.FormHost

When I run the program, the output I get is:

D:\Tools\rmfolder>regtest.pl [Values for 'HKEY_CLASSES_ROOT/Folder/shell'] 1. explore/ 2. open/ 3. xyzzy_1/ Deleting label 'xyzzy_1' ... Result of delete: 'The system cannot find the file specified. '

Can anyone suggest why the delete isn't apparently working (both from the error message, and the fact that it still shows up in the registry)?  Am I missing some other step or steps?  I'm using Win32::TieRegistry version 0.20 (which comes with my ActiveState Perl version 5.10.0); should I be updating to a later version of Win32::TieRegistry?

Thanks in advance for any help!


s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

In reply to Unable to delete registry keys using Win32::TieRegistry by liverpole

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-19 01:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found