Retrieving a registry data type using TieRegistry

A

ant_howell

Hi

I've been using the Win32::TieRegistry module to query the windows
registry and have so far managed to obtain some good results. However,
I appear to be having difficulty retrieving a registry data type such
as REG_DWORD or REG_SZ.

I've looked at the CPAN docs for TieRegistry and the extract below is
taken directly from the docs.

$swKey= $Registry->{"LMachine/Software/"};
$winKey= $swKey->{"Microsoft/Windows/CurrentVersion/"};
$userKey= $Registry->
{"CUser/Software/Microsoft/Windows/CurrentVersion/"};
$remoteKey= $Registry->{"//HostName/LMachine/"};

$progDir= $winKey->{"/ProgramFilesDir"}; # "C:\\Program Files"
$tip21= $winKey->{"Explorer/Tips//21"}; # Text of tip #21.
$winKey->ArrayValues(1);
( $devPath, $type )= $winKey->{"/DevicePath"};
# $devPath eq "%SystemRoot%\\inf"
# $type eq "REG_EXPAND_SZ" [if you have SetDualVar.pm installed]
# $type == REG_EXPAND_SZ() [if did C<use Win32::TieRegistry
qw:)REG_)>]

Now, I have SetDualVar installed, that is to say I installed it via ppm
but I don't get any value back for type and it is undefined. $devPath
returns an array reference.

I know I am missing something fundamental and its most likely to be
very simple but simple or not, I can't seem to determine the problem.

All I want to do is to be able to obtain a data type for a particular
registry key value.

Any help will be appreciated.

Regards

Ant H.
 
B

Brian McCauley

( $devPath, $type )= $winKey->{"/DevicePath"};
...I don't get any value back for type and it is undefined. $devPath
returns an array reference.

I know I am missing something fundamental and its most likely to be
very simple but simple or not, I can't seem to determine the problem.

Yes you have a list assignment with a scalar expression on the RHS.
This can only ever assign a single value and $type will always be
undef.
All I want to do is to be able to obtain a data type for a particular
registry key value.

Well I've not tried it but a glance at the documentation of
Win32::TieRegistry indicates you want:

( $devPath, $type ) = $winKey->GetValue("DevicePath");
 
A

ant_howell

Thanks Brian

Yep, its so obvious now.

Cheers


Brian said:
Yes you have a list assignment with a scalar expression on the RHS.
This can only ever assign a single value and $type will always be
undef.


Well I've not tried it but a glance at the documentation of
Win32::TieRegistry indicates you want:

( $devPath, $type ) = $winKey->GetValue("DevicePath");
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top