Index: src/shared/Utils.cpp |
=================================================================== |
--- a/src/shared/Utils.cpp |
+++ b/src/shared/Utils.cpp |
@@ -16,22 +16,24 @@ |
} |
+std::unique_ptr<OSVERSIONINFOEX> GetWindowsVersion() |
Felix Dahlke
2014/07/03 13:38:07
This seems like a refactoring, can we put it in a
Oleksandr
2014/07/03 13:51:49
It's addressing comments in this review. Shall we
Felix Dahlke
2014/07/03 13:56:33
Which comment? To switch to std::unique_ptr? That
Oleksandr
2014/07/03 14:00:42
http://codereview.adblockplus.org/5792731695677440
|
+{ |
+ std::unique_ptr<OSVERSIONINFOEX> osvi(new OSVERSIONINFOEX()); |
+ osvi->dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); |
+ GetVersionEx(reinterpret_cast<LPOSVERSIONINFO>(osvi.get())); |
+ return osvi; |
+} |
+ |
bool IsWindowsVistaOrLater() |
{ |
- OSVERSIONINFOEX osvi; |
- ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); |
- osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); |
- GetVersionEx(reinterpret_cast<LPOSVERSIONINFO>(&osvi)); |
- return osvi.dwMajorVersion >= 6; |
+ std::unique_ptr<OSVERSIONINFOEX> osvi = GetWindowsVersion(); |
+ return osvi->dwMajorVersion >= 6; |
} |
bool IsWindows8OrLater() |
{ |
- OSVERSIONINFOEX osvi; |
- ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); |
- osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); |
- GetVersionEx(reinterpret_cast<LPOSVERSIONINFO>(&osvi)); |
- return osvi.dwMajorVersion >= 6 && osvi.dwMinorVersion >= 2; |
+ std::unique_ptr<OSVERSIONINFOEX> osvi = GetWindowsVersion(); |
+ return (osvi->dwMajorVersion == 6 && osvi->dwMinorVersion >= 2) || osvi->dwMajorVersion > 6; |
} |
std::string ToUtf8String(const std::wstring& str) |