Chromium Code Reviews| Index: base/win/windows_version.cc |
| diff --git a/base/win/windows_version.cc b/base/win/windows_version.cc |
| index 3cf22d8ccdad71f77da35d1310b9b73b7ede46da..39e72721b191c39619a7b24691e8c72214afc189 100644 |
| --- a/base/win/windows_version.cc |
| +++ b/base/win/windows_version.cc |
| @@ -83,6 +83,28 @@ Version GetVersionFromKernel32() { |
| return VERSION_WIN_LAST; |
| } |
| +// Returns the the "UBR" value from the registry. Introduced in Windows 10, |
| +// this undocumented value appears to be similar to a patch number. |
| +// Returns 0 if the value does not exist or it could not be read. |
| +int GetUBR() { |
| + // The values under the CurrentVersion registry hive are mirrored under |
| + // the corresponding Wow6432 hive. |
| + constexpr wchar_t kRegKeyWindowsNTCurrentVersion[] = |
|
grt (UTC plus 2)
2016/11/15 20:59:09
"static constexpr ..." so that the string isn't pu
Sorin Jianu
2016/11/15 23:03:29
Done.
This had a massive impact, which I admit I
|
| + L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"; |
| + constexpr wchar_t kRegValUBR[] = L"UBR"; |
| + |
| + base::win::RegKey key; |
| + if (key.Open(HKEY_LOCAL_MACHINE, kRegKeyWindowsNTCurrentVersion, |
| + KEY_QUERY_VALUE) != ERROR_SUCCESS) { |
| + return 0; |
| + } |
| + |
| + DWORD ubr = 0; |
| + key.ReadValueDW(kRegValUBR, &ubr); |
|
grt (UTC plus 2)
2016/11/15 20:59:09
nit: i would use L"UBR" directly here since using
Sorin Jianu
2016/11/15 23:03:29
Done.
|
| + |
| + return static_cast<int>(ubr); |
| +} |
| + |
| } // namespace |
| // static |
| @@ -112,6 +134,7 @@ OSInfo::OSInfo() |
| version_number_.major = version_info.dwMajorVersion; |
| version_number_.minor = version_info.dwMinorVersion; |
| version_number_.build = version_info.dwBuildNumber; |
| + version_number_.patch = GetUBR(); |
| version_ = MajorMinorBuildToVersion( |
| version_number_.major, version_number_.minor, version_number_.build); |
| service_pack_.major = version_info.wServicePackMajor; |