Skip to content

Commit

Permalink
Change method for querying Windows OS version
Browse files Browse the repository at this point in the history
  • Loading branch information
justinshannon committed Jun 5, 2024
1 parent 20e1d45 commit 89d3b1d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 2 additions & 0 deletions client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ endif ()
# Set some Win32 Specific Settings
if (WIN32)
set(gui_TYPE WIN32)
set(LIB_NTDLL Ntdll) # used to query Windows version
endif (WIN32)

# Set some Apple MacOS Specific settings
Expand Down Expand Up @@ -222,6 +223,7 @@ target_link_libraries(${PROJECT_NAME}
${LIB_VATSIM_AUTH}
${LIB_NNG}
${LIB_ZIP}
${LIB_NTDLL}
msgpack-cxx
vatsim-auth
qtpromise
Expand Down
28 changes: 27 additions & 1 deletion client/src/appcore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,32 @@

using namespace xpilot;

#if defined(Q_OS_WIN)
#include <Windows.h>

#ifndef NTSTATUS
typedef LONG NTSTATUS;
#endif

#ifndef NTAPI
#define NTAPI __stdcall
#endif

extern "C" {
NTSTATUS NTAPI RtlGetVersion(PRTL_OSVERSIONINFOW lpVersionInformation);
}

bool IsWindows10OrNewer() {
RTL_OSVERSIONINFOW osInfo = {0};
osInfo.dwOSVersionInfoSize = sizeof(osInfo);
NTSTATUS status = RtlGetVersion(&osInfo);
if (status == 0) {
return osInfo.dwMajorVersion >= 10;
}
return false;
}
#endif

static QObject *appConfigSingleton(QQmlEngine *, QJSEngine *)
{
return AppConfig::getInstance();
Expand All @@ -84,7 +110,7 @@ int xpilot::Main(int argc, char* argv[])
app.setWindowIcon(QIcon(":/Resources/Icons/AppIcon.ico"));

#if defined(Q_OS_WIN)
if(QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows10_1809) {
if(!IsWindows10OrNewer()) {
QMessageBox::critical(nullptr, "Unsupported Windows Version", "Your Windows version is not supported. xPilot requires Windows 10 or newer.");
return 1;
}
Expand Down

0 comments on commit 89d3b1d

Please sign in to comment.