| 1 | package System::Info::Windows; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 2 | ▶ | use base "System::Info::Base"; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 2 | our $VERSION = "0.051"; | |||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | =head1 NAME | ||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | System::Info::Windows - Object for specific Windows info. | ||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | =head1 DESCRIPTION | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | =head2 $si->prepare_sysinfo | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | Use os-specific tools to find out more about the system. | ||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | =cut | ||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 0 | ▶ | sub prepare_sysinfo { | ||||||||||||||||||
|
Subroutine
prepare_sysinfo: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||
| 23 | 0 | my $self = shift; | |||||||||||||||||||
| 24 | 0 | $self->SUPER::prepare_sysinfo; | |||||||||||||||||||
| 25 | 0 | $self->prepare_os; | |||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 0 | my $reginfo = __get_registry_sysinfo (); | |||||||||||||||||||
| 28 | 0 | my $envinfo = __get_environment_sysinfo (); | |||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 0 | for my $key (qw/__cpu_type __cpu __cpu_count/) { | |||||||||||||||||||
| 31 | 0 | ▶ | my $value = $reginfo->{$key} || $envinfo->{$key}; | ||||||||||||||||||
|
Condition0%0/3
$reginfo->{$key} || $envinfo->{$key}
MC/DC0%0/2
$reginfo->{$key} || $envinfo->{$key}
$reginfo->{$key}
$envinfo->{$key}
Truth table0%0/3
A || B
A= $reginfo->{$key}B= $envinfo->{$key}
| |||||||||||||||||||||
| 32 | 0 | ▶ | $value and $self->{$key} = $value; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 33 | } | ||||||||||||||||||||
| 34 | 0 | return $self; | |||||||||||||||||||
| 35 | } # prepare_sysinfo | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | =head2 $si->prepare_os | ||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | Use os-specific tools to find out more about the operating system. | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | =cut | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 0 | ▶ | sub prepare_os { | ||||||||||||||||||
|
Subroutine
prepare_os: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 44 | 0 | my $self = shift; | |||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 0 | eval { require Win32 }; | |||||||||||||||||||
| 47 | 0 | ▶ | $@ and return; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | 0 | my $os = $self->_os; | |||||||||||||||||||
| 50 | # ("Win7", "Windows 7 Professional (64-bit) Service Pack 1") | ||||||||||||||||||||
| 51 | 0 | $os = "$^O - " . join " " => Win32::GetOSName (); | |||||||||||||||||||
| 52 | 0 | $os =~ s/Service\s+Pack\s+/SP/; | |||||||||||||||||||
| 53 | 0 | $self->{__os} = $os; | |||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | # Windows 7 Professional (64-bit) Service Pack 1 | ||||||||||||||||||||
| 56 | 0 | $self->{__osname} = Win32::GetOSDisplayName (); | |||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | # https://metacpan.org/pod/Win32#Win32::GetOSVersion() | ||||||||||||||||||||
| 59 | # ("Service Pack 1", 6, 1, 7601, 2, 1, 0, 0x100, 1) | ||||||||||||||||||||
| 60 | 0 | my ($name, $major, $minor, $build, $id, | |||||||||||||||||||
| 61 | $spmaj, $spmin, $suitemask, $producttype) = Win32::GetOSVersion (); | ||||||||||||||||||||
| 62 | 0 | $self->{__osvers} = join "." => $major, $minor, $build; | |||||||||||||||||||
| 63 | } # prepare_os | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | 0 | ▶ | sub __get_registry_sysinfo { | ||||||||||||||||||
|
Subroutine
__get_registry_sysinfo: not called CC=3 SCAR=24.8
| |||||||||||||||||||||
| 66 | 0 | eval { require Win32::TieRegistry }; | |||||||||||||||||||
| 67 | 0 | ▶ | $@ and return; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | 0 | Win32::TieRegistry->import; | |||||||||||||||||||
| 70 | 0 | my $Registry = $Win32::TieRegistry::Registry->Open ( | |||||||||||||||||||
| 71 | "", { Access => 0x2000000 }); | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | 0 | my $basekey = join "\\" => | |||||||||||||||||||
| 74 | qw(LMachine HARDWARE DESCRIPTION System CentralProcessor); | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | 0 | my $pnskey = "$basekey\\0\\ProcessorNameString"; | |||||||||||||||||||
| 77 | 0 | my $cpustr = $Registry->{$pnskey}; | |||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | 0 | my $idkey = "$basekey\\0\\Identifier"; | |||||||||||||||||||
| 80 | 0 | ▶ | $cpustr ||= $Registry->{ $idkey }; | ||||||||||||||||||
|
Condition0%0/3
$cpustr ||= $Registry->{$idkey}
MC/DC0%0/2
$cpustr ||= $Registry->{$idkey}
$cpustr
$Registry->{$idkey}
Truth table0%0/3
A ||= B
A= $cpustrB= $Registry->{$idkey}
| |||||||||||||||||||||
| 81 | 0 | $cpustr =~ tr/ / /s; | |||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | 0 | my $mhzkey = "$basekey\\0\\~MHz"; | |||||||||||||||||||
| 84 | 0 | $cpustr .= sprintf "(~%d MHz)", hex $Registry->{$mhzkey}; | |||||||||||||||||||
| 85 | 0 | my $cpu = $cpustr; | |||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | 0 | my $ncpu = keys %{$Registry->{$basekey}}; | |||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | 0 | my ($cpu_type) = $Registry->{$idkey} =~ /^(\S+)/; | |||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | return { | ||||||||||||||||||||
| 92 | 0 | __cpu_type => $cpu_type, | |||||||||||||||||||
| 93 | __cpu => $cpu, | ||||||||||||||||||||
| 94 | __cpu_count => $ncpu, | ||||||||||||||||||||
| 95 | }; | ||||||||||||||||||||
| 96 | } # __get_registry_sysinfo | ||||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | 0 | ▶ | sub __get_environment_sysinfo { | ||||||||||||||||||
|
Subroutine
__get_environment_sysinfo: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 99 | return { | ||||||||||||||||||||
| 100 | __cpu_type => $ENV{PROCESSOR_ARCHITECTURE}, | ||||||||||||||||||||
| 101 | __cpu => $ENV{PROCESSOR_IDENTIFIER}, | ||||||||||||||||||||
| 102 | __cpu_count => $ENV{NUMBER_OF_PROCESSORS}, | ||||||||||||||||||||
| 103 | 0 | }; | |||||||||||||||||||
| 104 | } # __get_environment_sysinfo | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | 2 | 1; | |||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | __END__ | ||||||||||||||||||||