tags:

views:

180

answers:

2

I have a perl function that takes an open registry key object. Now, I want to get the name of the key this object represents. How do I get the key Name?

I am using Win32::Registry module.

A: 

According to this documentation you do it like this:

my @keys;
$reg_obj->GetKeys(\@keys);

Populates the supplied array reference with the names of all the keys within the registry object $reg_obj.

But they also say: obsolete, use Win32::TieRegistry

Nifle
I want to get the KeyName for $reg_obj not the key names of the children.
Canopus
+1  A: 

Browsing through the source, it doesn't look like Win32::Registry will let you take the handle and get back to the Key. I see three ways around this:

  1. Maintain a list of returned objects from Open and the path to them yourself.
  2. Hack the module (subclass it, change the source) to do #1 for you.
  3. Or extend the Win32::Registry API to do what's shown in this stackoverflow answer: http://stackoverflow.com/questions/937044/determine-path-to-registry-key-from-hkey-handle-in-c
clintp