in reply to Re: Need help with Win32::TieRegistry
in thread Need help with Win32::TieRegistry

you need administrative rights to fetch this
Do you? Win32::SystemInfo works with user privileges. And the module is reading from the Registry too. Addendum: It is using a combination of Win32::TieRegistry and the GetSystemInfo function from Win32::API. Here's the relevant function.
use Win32::SystemInfo; use Data::Dumper; my %phash; Win32::SystemInfo::ProcessorInfo(%phash); print Dumper (\%phash);
Yields on my system, running as normal user:
$VAR1 = { 'Processor3' => { 'Identifier' => 'Intel64 Family 6 Model 60 + Stepping 3', 'ProcessorName' => 'Intel(R) Core(TM) i5-4 +440 CPU @ 3.10GHz', 'VendorIdentifier' => 'GenuineIntel', 'MHZ' => 3093 }, 'NumProcessors' => 4, 'Processor2' => { 'MHZ' => 3093, 'VendorIdentifier' => 'GenuineIntel', 'Identifier' => 'Intel64 Family 6 Model 60 + Stepping 3', 'ProcessorName' => 'Intel(R) Core(TM) i5-4 +440 CPU @ 3.10GHz' }, 'Processor0' => { 'MHZ' => 3093, 'VendorIdentifier' => 'GenuineIntel', 'ProcessorName' => 'Intel(R) Core(TM) i5-4 +440 CPU @ 3.10GHz', 'Identifier' => 'Intel64 Family 6 Model 60 + Stepping 3' }, 'Processor1' => { 'ProcessorName' => 'Intel(R) Core(TM) i5-4 +440 CPU @ 3.10GHz', 'Identifier' => 'Intel64 Family 6 Model 60 + Stepping 3', 'VendorIdentifier' => 'GenuineIntel', 'MHZ' => 3093 } };


holli

You can lead your users to water, but alas, you cannot drown them.

Replies are listed 'Best First'.
Re^3: Need help with Win32::TieRegistry
by CrashBlossom (Beadle) on Jul 01, 2019 at 21:03 UTC
    After reading holli's observation that SystemInfo uses TieRegistry, I took look at the source for SystemInfo. The following bit at the top is lifted almost verbatim from SystemInfo:
    use strict; use warnings; use Win32::TieRegistry qw(:KEY_); $Registry->Delimiter("/"); my $procinfo = $Registry->Open( "HKEY_LOCAL_MACHINE/HARDWARE/DESCRIPTION/System/Centra +lProcessor/0", { Access => KEY_READ() } ); PrintHash($procinfo); sub PrintHash { my ($hashref, $indent) = @_; my %hash = %{$hashref}; $indent += 2; my $maxsize = 0; foreach my $key (keys %hash) { $maxsize = length $key if (length $key > $maxsize); } foreach my $key (sort keys %hash) { printf "%*sKey: %-*s Value: %s\n", $indent, "", $maxsize, $key +, $hash{$key}; if (ref $hash{$key} eq 'ARRAY') { PrintArray($hash{$key}, $ind +ent); } if (ref $hash{$key} eq 'HASH') { PrintHash($hash{$key}, $inde +nt); } } } sub PrintArray { my ($array, $indent) = @_; my @arr = @{$array}; $indent += 2; my $cnt = 0; foreach my $elem (@arr) { printf("%*s%2d. %s\n", $indent, "", $cnt, $elem); if (ref $elem eq 'ARRAY') { PrintArray($elem, $indent); } if (ref $elem eq 'HASH') { PrintHash($elem, $indent); } ++$cnt; } }
    Here is the result:
    Key: /Component Information Value: Key: /Configuration Data Value:          Key: /FeatureSet Value: 0x3D1B3FFF Key: /Identifier Value: Intel64 Family 6 Model 60 Ste +pping 3 Key: /Platform Specific Field 1 Value: 0x00000020 Key: /Previous Update Revision Value:  Key: /ProcessorNameString Value: Intel(R) Core(TM) i7-4700HQ C +PU @ 2.40GHz Key: /Update Revision Value: % Key: /Update Status Value: 0x00000000 Key: /VendorIdentifier Value: GenuineIntel Key: /~MHz Value: 0x0000095A

    Apparently "Access => KEY_READ()" indicates that read-only access is requested, which makes everything good.

    Thanks for the responses. This issue is resolved

Re^3: Need help with Win32::TieRegistry
by CrashBlossom (Beadle) on Jul 01, 2019 at 14:16 UTC

    I suppose TieRegistry requires admin rights because it allows you to change the registry. In any case, SystemInfo provides the information I need for this particular problem, so thanks for the tip!