Skip to content

Commit 8ad41c8

Browse files
committed
Added Win2012/Win8 detection; without any added constants.
1 parent 2d7d14e commit 8ad41c8

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

Win32.pm

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ sub GetOSDisplayName {
292292
$desc =~ s/^\s*//;
293293
s/(200.)/$name Server $1/;
294294
}
295-
s/^Windows (200[38])/Windows Server $1/;
295+
s/^Windows (20(03|08|12))/Windows Server $1/;
296296
}
297297
}
298298
$name .= " $desc" if length $desc;
@@ -460,8 +460,16 @@ sub _GetOSName {
460460
$desc = "R2";
461461
}
462462
}
463+
elsif ($minor == 2) {
464+
if ($producttype == VER_NT_WORKSTATION) {
465+
$os = "8";
466+
}
467+
else {
468+
$os = "2012";
469+
}
470+
}
463471

464-
if ($productinfo == PRODUCT_ULTIMATE) {
472+
if ($productinfo == PRODUCT_ULTIMATE) {
465473
$desc .= " Ultimate";
466474
}
467475
elsif ($productinfo == PRODUCT_HOME_PREMIUM) {
@@ -970,6 +978,8 @@ Currently known values for ID MAJOR and MINOR are as follows:
970978
Windows Server 2008 2 6 0
971979
Windows 7 2 6 1
972980
Windows Server 2008 R2 2 6 1
981+
Windows 8 2 6 2
982+
Windows Server 2012 2 6 2
973983
974984
On Windows NT 4 SP6 and later this function returns the following
975985
additional values: SPMAJOR, SPMINOR, SUITEMASK, PRODUCTTYPE.
@@ -986,6 +996,10 @@ The version numbers for Windows 7 and Windows Server 2008 R2 are
986996
identical; the PRODUCTTYPE field must be used to differentiate between
987997
them.
988998
999+
The version numbers for Windows 8 and Windows Server 2012 are
1000+
identical; the PRODUCTTYPE field must be used to differentiate between
1001+
them.
1002+
9891003
SPMAJOR and SPMINOR are are the version numbers of the latest
9901004
installed service pack.
9911005
@@ -1016,9 +1030,9 @@ constants.
10161030
PRODUCTTYPE provides additional information about the system. It should
10171031
be one of the following integer values:
10181032
1019-
1 - Workstation (NT 4, 2000 Pro, XP Home, XP Pro, Vista)
1033+
1 - Workstation (NT 4, 2000 Pro, XP Home, XP Pro, Vista, etc)
10201034
2 - Domaincontroller
1021-
3 - Server (2000 Server, Server 2003, Server 2008)
1035+
3 - Server (2000 Server, Server 2003, Server 2008, etc)
10221036
10231037
Note that a server that is also a domain controller is reported as
10241038
PRODUCTTYPE 2 (Domaincontroller) and not PRODUCTTYPE 3 (Server).

t/GetOSName.t

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,9 @@ my @dual_tests = (
9999
["7 [Enterprise]", "7", 2, 6, 1, 0x04 ],
100100
["7 [Ultimate]", "7", 2, 6, 1, 0x01 ],
101101

102-
102+
["8", "8", 2, 6, 2 ],
103103
["2008 [R2]", "2008", 2, 6, 1, 0x00, 2, 89 ],
104+
["2012", "2012", 2, 6, 2, 0x00, 2, 89 ],
104105
["[Small Business Server] 2008 R2", "2008", 2, 6, 1, 0x09, 2, 89 ],
105106

106107
);
@@ -127,7 +128,7 @@ sub check {
127128
# and 2003/2008 start with "Windows Server"
128129
unless ($pretty eq "Win32s") {
129130
my $prefix = "Windows";
130-
$prefix .= " Server" if $pretty =~ /^200[38]/;
131+
$prefix .= " Server" if $pretty =~ /^20(03|08|12)/;
131132
$pretty = "$prefix $pretty";
132133
}
133134

0 commit comments

Comments
 (0)