OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/win/windows_version.h" | 5 #include "base/win/windows_version.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 | 10 |
11 namespace base { | 11 namespace base { |
(...skipping 18 matching lines...) Expand all Loading... |
30 OSInfo::OSInfo() | 30 OSInfo::OSInfo() |
31 : version_(VERSION_PRE_XP), | 31 : version_(VERSION_PRE_XP), |
32 architecture_(OTHER_ARCHITECTURE), | 32 architecture_(OTHER_ARCHITECTURE), |
33 wow64_status_(GetWOW64StatusForProcess(GetCurrentProcess())) { | 33 wow64_status_(GetWOW64StatusForProcess(GetCurrentProcess())) { |
34 OSVERSIONINFOEX version_info = { sizeof version_info }; | 34 OSVERSIONINFOEX version_info = { sizeof version_info }; |
35 GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&version_info)); | 35 GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&version_info)); |
36 version_number_.major = version_info.dwMajorVersion; | 36 version_number_.major = version_info.dwMajorVersion; |
37 version_number_.minor = version_info.dwMinorVersion; | 37 version_number_.minor = version_info.dwMinorVersion; |
38 version_number_.build = version_info.dwBuildNumber; | 38 version_number_.build = version_info.dwBuildNumber; |
39 if ((version_number_.major == 5) && (version_number_.minor > 0)) { | 39 if ((version_number_.major == 5) && (version_number_.minor > 0)) { |
40 version_ = (version_number_.minor == 1) ? VERSION_XP : VERSION_SERVER_2003; | 40 // Treat XP Pro x64, Server 2003, Home Server, and Server 2003 R2 as XP. |
| 41 version_ = VERSION_XP; |
41 } else if (version_number_.major == 6) { | 42 } else if (version_number_.major == 6) { |
42 if (version_info.wProductType == VER_NT_WORKSTATION) { | 43 switch (version_number_.minor) { |
43 switch (version_number_.minor) { | 44 case 0: |
44 case 0: | 45 // Treat Windows Server 2008 the same as Windows Vista. |
45 version_ = VERSION_VISTA; | 46 version_ = VERSION_VISTA; |
46 break; | 47 break; |
47 case 1: | 48 case 1: |
48 version_ = VERSION_WIN7; | 49 // Treat Windows Server 2008 R2 the same as Windows 7. |
49 break; | 50 version_ = VERSION_WIN7; |
50 default: // case 2 appears to be win8. | 51 break; |
51 version_ = VERSION_WIN8; | 52 default: |
52 } | 53 DCHECK_EQ(version_number_.minor, 2); |
53 } else { | 54 // Treat Windows Server 2012 the same as Windows 8. |
54 version_ = VERSION_SERVER_2008; | 55 version_ = VERSION_WIN8; |
| 56 break; |
55 } | 57 } |
56 } else if (version_number_.major > 6) { | 58 } else if (version_number_.major > 6) { |
57 NOTREACHED(); | 59 NOTREACHED(); |
58 version_ = VERSION_WIN_LAST; | 60 version_ = VERSION_WIN_LAST; |
59 } | 61 } |
60 service_pack_.major = version_info.wServicePackMajor; | 62 service_pack_.major = version_info.wServicePackMajor; |
61 service_pack_.minor = version_info.wServicePackMinor; | 63 service_pack_.minor = version_info.wServicePackMinor; |
62 | 64 |
63 SYSTEM_INFO system_info = { 0 }; | 65 SYSTEM_INFO system_info = { 0 }; |
64 GetNativeSystemInfo(&system_info); | 66 GetNativeSystemInfo(&system_info); |
(...skipping 21 matching lines...) Expand all Loading... |
86 return WOW64_UNKNOWN; | 88 return WOW64_UNKNOWN; |
87 return is_wow64 ? WOW64_ENABLED : WOW64_DISABLED; | 89 return is_wow64 ? WOW64_ENABLED : WOW64_DISABLED; |
88 } | 90 } |
89 | 91 |
90 Version GetVersion() { | 92 Version GetVersion() { |
91 return OSInfo::GetInstance()->version(); | 93 return OSInfo::GetInstance()->version(); |
92 } | 94 } |
93 | 95 |
94 } // namespace win | 96 } // namespace win |
95 } // namespace base | 97 } // namespace base |
OLD | NEW |