OLD | NEW |
1 // Copyright (c) 2012 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 <memory> |
| 10 |
9 #include "base/file_version_info_win.h" | 11 #include "base/file_version_info_win.h" |
10 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
11 #include "base/logging.h" | 13 #include "base/logging.h" |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
14 #include "base/win/registry.h" | 15 #include "base/win/registry.h" |
15 | 16 |
16 namespace { | 17 namespace { |
17 typedef BOOL (WINAPI *GetProductInfoPtr)(DWORD, DWORD, DWORD, DWORD, PDWORD); | 18 typedef BOOL (WINAPI *GetProductInfoPtr)(DWORD, DWORD, DWORD, DWORD, PDWORD); |
18 } // namespace | 19 } // namespace |
19 | 20 |
20 namespace base { | 21 namespace base { |
21 namespace win { | 22 namespace win { |
22 | 23 |
(...skipping 30 matching lines...) Expand all Loading... |
53 return VERSION_WIN_LAST; | 54 return VERSION_WIN_LAST; |
54 } | 55 } |
55 | 56 |
56 return VERSION_PRE_XP; | 57 return VERSION_PRE_XP; |
57 } | 58 } |
58 | 59 |
59 // Retrieve a version from kernel32. This is useful because when running in | 60 // Retrieve a version from kernel32. This is useful because when running in |
60 // compatibility mode for a down-level version of the OS, the file version of | 61 // compatibility mode for a down-level version of the OS, the file version of |
61 // kernel32 will still be the "real" version. | 62 // kernel32 will still be the "real" version. |
62 Version GetVersionFromKernel32() { | 63 Version GetVersionFromKernel32() { |
63 scoped_ptr<FileVersionInfoWin> file_version_info( | 64 std::unique_ptr<FileVersionInfoWin> file_version_info( |
64 static_cast<FileVersionInfoWin*>( | 65 static_cast<FileVersionInfoWin*>( |
65 FileVersionInfoWin::CreateFileVersionInfo( | 66 FileVersionInfoWin::CreateFileVersionInfo( |
66 base::FilePath(FILE_PATH_LITERAL("kernel32.dll"))))); | 67 base::FilePath(FILE_PATH_LITERAL("kernel32.dll"))))); |
67 if (file_version_info) { | 68 if (file_version_info) { |
68 const int major = | 69 const int major = |
69 HIWORD(file_version_info->fixed_file_info()->dwFileVersionMS); | 70 HIWORD(file_version_info->fixed_file_info()->dwFileVersionMS); |
70 const int minor = | 71 const int minor = |
71 LOWORD(file_version_info->fixed_file_info()->dwFileVersionMS); | 72 LOWORD(file_version_info->fixed_file_info()->dwFileVersionMS); |
72 const int build = | 73 const int build = |
73 HIWORD(file_version_info->fixed_file_info()->dwFileVersionLS); | 74 HIWORD(file_version_info->fixed_file_info()->dwFileVersionLS); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 return WOW64_UNKNOWN; | 217 return WOW64_UNKNOWN; |
217 return is_wow64 ? WOW64_ENABLED : WOW64_DISABLED; | 218 return is_wow64 ? WOW64_ENABLED : WOW64_DISABLED; |
218 } | 219 } |
219 | 220 |
220 Version GetVersion() { | 221 Version GetVersion() { |
221 return OSInfo::GetInstance()->version(); | 222 return OSInfo::GetInstance()->version(); |
222 } | 223 } |
223 | 224 |
224 } // namespace win | 225 } // namespace win |
225 } // namespace base | 226 } // namespace base |
OLD | NEW |