| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 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 version_ = (version_number_.minor == 1) ? VERSION_XP : VERSION_SERVER_2003; |
| 41 } else if (version_number_.major == 6) { | 41 } else if (version_number_.major == 6) { |
| 42 if (version_info.wProductType == VER_NT_WORKSTATION) | 42 if (version_info.wProductType == VER_NT_WORKSTATION) { |
| 43 version_ = (version_number_.minor == 0) ? VERSION_VISTA : VERSION_WIN7; | 43 switch (version_number_.minor) { |
| 44 else | 44 case 0: |
| 45 version_ = VERSION_VISTA; |
| 46 break; |
| 47 case 1: |
| 48 version_ = VERSION_WIN7; |
| 49 break; |
| 50 default: // case 2 appears to be win8. |
| 51 version_ = VERSION_WIN8; |
| 52 } |
| 53 } else { |
| 45 version_ = VERSION_SERVER_2008; | 54 version_ = VERSION_SERVER_2008; |
| 55 } |
| 46 } else if (version_number_.major > 6) { | 56 } else if (version_number_.major > 6) { |
| 47 version_ = VERSION_WIN7; | 57 NOTREACHED(); |
| 58 version_ = VERSION_WIN_LAST; |
| 48 } | 59 } |
| 49 service_pack_.major = version_info.wServicePackMajor; | 60 service_pack_.major = version_info.wServicePackMajor; |
| 50 service_pack_.minor = version_info.wServicePackMinor; | 61 service_pack_.minor = version_info.wServicePackMinor; |
| 51 | 62 |
| 52 SYSTEM_INFO system_info = { 0 }; | 63 SYSTEM_INFO system_info = { 0 }; |
| 53 GetNativeSystemInfo(&system_info); | 64 GetNativeSystemInfo(&system_info); |
| 54 switch (system_info.wProcessorArchitecture) { | 65 switch (system_info.wProcessorArchitecture) { |
| 55 case PROCESSOR_ARCHITECTURE_INTEL: architecture_ = X86_ARCHITECTURE; break; | 66 case PROCESSOR_ARCHITECTURE_INTEL: architecture_ = X86_ARCHITECTURE; break; |
| 56 case PROCESSOR_ARCHITECTURE_AMD64: architecture_ = X64_ARCHITECTURE; break; | 67 case PROCESSOR_ARCHITECTURE_AMD64: architecture_ = X64_ARCHITECTURE; break; |
| 57 case PROCESSOR_ARCHITECTURE_IA64: architecture_ = IA64_ARCHITECTURE; break; | 68 case PROCESSOR_ARCHITECTURE_IA64: architecture_ = IA64_ARCHITECTURE; break; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 75 return WOW64_UNKNOWN; | 86 return WOW64_UNKNOWN; |
| 76 return is_wow64 ? WOW64_ENABLED : WOW64_DISABLED; | 87 return is_wow64 ? WOW64_ENABLED : WOW64_DISABLED; |
| 77 } | 88 } |
| 78 | 89 |
| 79 Version GetVersion() { | 90 Version GetVersion() { |
| 80 return OSInfo::GetInstance()->version(); | 91 return OSInfo::GetInstance()->version(); |
| 81 } | 92 } |
| 82 | 93 |
| 83 } // namespace win | 94 } // namespace win |
| 84 } // namespace base | 95 } // namespace base |
| OLD | NEW |