line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package System::Info::Windows; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
13
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
56
|
|
4
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
51
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
20
|
use base "System::Info::Base"; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1339
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
sub prepare_sysinfo { |
23
|
0
|
|
|
0
|
1
|
|
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
|
|
0
|
|
|
|
my $value = $reginfo->{$key} || $envinfo->{$key}; |
32
|
0
|
0
|
|
|
|
|
$value and $self->{$key} = $value; |
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
|
|
|
|
|
|
|
sub prepare_os { |
44
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
eval { require Win32 }; |
|
0
|
|
|
|
|
|
|
47
|
0
|
0
|
|
|
|
|
$@ and return; |
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
|
|
|
|
|
|
|
sub __get_registry_sysinfo { |
66
|
0
|
|
|
0
|
|
|
eval { require Win32::TieRegistry }; |
|
0
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
|
$@ and return; |
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
|
|
0
|
|
|
|
$cpustr ||= $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}}; |
|
0
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
sub __get_environment_sysinfo { |
99
|
|
|
|
|
|
|
return { |
100
|
|
|
|
|
|
|
__cpu_type => $ENV{PROCESSOR_ARCHITECTURE}, |
101
|
|
|
|
|
|
|
__cpu => $ENV{PROCESSOR_IDENTIFIER}, |
102
|
|
|
|
|
|
|
__cpu_count => $ENV{NUMBER_OF_PROCESSORS}, |
103
|
0
|
|
|
0
|
|
|
}; |
104
|
|
|
|
|
|
|
} # __get_environment_sysinfo |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
1; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
__END__ |