aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradrido <robots_only_adrido@gmx.com>2017-10-07 15:13:13 +0200
committerSmallJoker <mk939@ymail.com>2018-06-03 17:31:59 +0200
commitd215198fe8dd9f19e8dc815bdf13989520318758 (patch)
tree6df5b9ed4dbcc2ecebea9abbcf43b34e57310837
parentc56c3d8d6f5d050acea30a70c058fd442cc41389 (diff)
downloadminetest-d215198fe8dd9f19e8dc815bdf13989520318758.tar.gz
minetest-d215198fe8dd9f19e8dc815bdf13989520318758.tar.bz2
minetest-d215198fe8dd9f19e8dc815bdf13989520318758.zip
Replace deprecated WINAPI GetVersionInfoEx (#6496)
* Replace deprecated WINAPI GetVersionInfoEx
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/porting.cpp36
2 files changed, 24 insertions, 14 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 7c1a4eee0..b1650f376 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -268,7 +268,7 @@ if(WIN32)
else() # Probably MinGW = GCC
set(PLATFORM_LIBS "")
endif()
- set(PLATFORM_LIBS ws2_32.lib shlwapi.lib ${PLATFORM_LIBS})
+ set(PLATFORM_LIBS ws2_32.lib version.lib shlwapi.lib ${PLATFORM_LIBS})
# Zlib stuff
set(ZLIB_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/../../zlib/zlib-1.2.5"
diff --git a/src/porting.cpp b/src/porting.cpp
index 10b6fc940..0a9de2a59 100644
--- a/src/porting.cpp
+++ b/src/porting.cpp
@@ -32,6 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <windows.h>
#include <wincrypt.h>
#include <algorithm>
+ #include <shlwapi.h>
#endif
#if !defined(_WIN32)
#include <unistd.h>
@@ -181,20 +182,26 @@ bool detectMSVCBuildDir(const std::string &path)
std::string get_sysinfo()
{
#ifdef _WIN32
- OSVERSIONINFO osvi;
+
std::ostringstream oss;
- std::string tmp;
- ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
- osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- GetVersionEx(&osvi);
- tmp = osvi.szCSDVersion;
- std::replace(tmp.begin(), tmp.end(), ' ', '_');
-
- oss << "Windows/" << osvi.dwMajorVersion << "."
- << osvi.dwMinorVersion;
- if (osvi.szCSDVersion[0])
- oss << "-" << tmp;
- oss << " ";
+ LPSTR filePath = new char[MAX_PATH];
+ UINT blockSize;
+ VS_FIXEDFILEINFO *fixedFileInfo;
+
+ GetSystemDirectoryA(filePath, MAX_PATH);
+ PathAppendA(filePath, "kernel32.dll");
+
+ DWORD dwVersionSize = GetFileVersionInfoSizeA(filePath, NULL);
+ LPBYTE lpVersionInfo = new BYTE[dwVersionSize];
+
+ GetFileVersionInfoA(filePath, 0, dwVersionSize, lpVersionInfo);
+ VerQueryValueA(lpVersionInfo, "\\", (LPVOID *)&fixedFileInfo, &blockSize);
+
+ oss << "Windows/"
+ << HIWORD(fixedFileInfo->dwProductVersionMS) << '.' // Major
+ << LOWORD(fixedFileInfo->dwProductVersionMS) << '.' // Minor
+ << HIWORD(fixedFileInfo->dwProductVersionLS) << ' '; // Build
+
#ifdef _WIN64
oss << "x86_64";
#else
@@ -205,6 +212,9 @@ std::string get_sysinfo()
oss << "x86";
#endif
+ delete[] lpVersionInfo;
+ delete[] filePath;
+
return oss.str();
#else
struct utsname osinfo;