forked from Mirrorlandia_minetest/minetest
Replace deprecated WINAPI GetVersionInfoEx (#6496)
* Replace deprecated WINAPI GetVersionInfoEx
This commit is contained in:
parent
d386586201
commit
c830347a57
@ -268,7 +268,7 @@ if(WIN32)
|
|||||||
else() # Probably MinGW = GCC
|
else() # Probably MinGW = GCC
|
||||||
set(PLATFORM_LIBS "")
|
set(PLATFORM_LIBS "")
|
||||||
endif()
|
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
|
# Zlib stuff
|
||||||
set(ZLIB_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/../../zlib/zlib-1.2.5"
|
set(ZLIB_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/../../zlib/zlib-1.2.5"
|
||||||
|
@ -32,6 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <wincrypt.h>
|
#include <wincrypt.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <shlwapi.h>
|
||||||
#endif
|
#endif
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -173,20 +174,26 @@ bool detectMSVCBuildDir(const std::string &path)
|
|||||||
std::string get_sysinfo()
|
std::string get_sysinfo()
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#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 << "."
|
std::ostringstream oss;
|
||||||
<< osvi.dwMinorVersion;
|
LPSTR filePath = new char[MAX_PATH];
|
||||||
if (osvi.szCSDVersion[0])
|
UINT blockSize;
|
||||||
oss << "-" << tmp;
|
VS_FIXEDFILEINFO *fixedFileInfo;
|
||||||
oss << " ";
|
|
||||||
|
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
|
#ifdef _WIN64
|
||||||
oss << "x86_64";
|
oss << "x86_64";
|
||||||
#else
|
#else
|
||||||
@ -197,6 +204,9 @@ std::string get_sysinfo()
|
|||||||
oss << "x86";
|
oss << "x86";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
delete[] lpVersionInfo;
|
||||||
|
delete[] filePath;
|
||||||
|
|
||||||
return oss.str();
|
return oss.str();
|
||||||
#else
|
#else
|
||||||
struct utsname osinfo;
|
struct utsname osinfo;
|
||||||
|
Loading…
Reference in New Issue
Block a user