Hey everyone!
I've developed a simple code to help fix compatibility issues with Windows 11, making it easier for RAN Online to run the latest OS. Also, added compatibility program up to latest Windows Server 2025. Since I know many of you face similar frustrations, I’m making this code available for free! You just need to merge it or replace the whole GetWinVer cpp and h files.
For the context, we met Juver long time ago. And he told me that most ran private server can't even fixed the windows 10 compatibility in ran source. So I did the fixing of GetWinVer code to make it compatible even the incoming windows 11. And as we know, Windows 10 will stop the free updates after October 14, 2025.
Source: https://www.microsoft.com/en-ph/windows/end-of-support?r=1#:~:text=Your%20PC%20will%20continue%20to,provide%20Windows%2010%20technical%20support
Feel free to download, use, and share it with others. I believe in keeping Ran Community great again, and this is my way of contributing to the community. But please don't remove my credits :)
============
GetWinVer.cpp
============
// GetWinVer.cpp Version 1.2 (Updated for Windows 11)
//
// Original copyright (C) 2001-2003 Hans Dietrich
// Update 2025 by Emolista2
//
// This software is released into the public domain.
// You are free to use it in any way you like, except
// that you may not sell this source code.
//
// This software is provided "as is" with no expressed
// or implied warranty. I accept no liability for any
// damage or loss of business that this software may cause.
//
///////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "tchar.h"
#include "GetWinVer.h"
#include <windows.h>
#include <stdio.h>
typedef LONG(WINAPI* RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);
BOOL GetWinVer(LPTSTR pszVersion, int* nVersion, LPTSTR pszMajorMinorBuild, LPTSTR pszServicePack)
{
if (!pszVersion || !nVersion || !pszMajorMinorBuild) return FALSE;
lstrcpy(pszVersion, WUNKNOWNSTR);
*nVersion = WUNKNOWN;
RTL_OSVERSIONINFOEXW osInfo = { 0 };
osInfo.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW);
HMODULE hMod = GetModuleHandle(TEXT("ntdll.dll"));
if (hMod)
{
RtlGetVersionPtr RtlGetVersion = (RtlGetVersionPtr)GetProcAddress(hMod, "RtlGetVersion");
if (RtlGetVersion)
{
RtlGetVersion(reinterpret_cast<PRTL_OSVERSIONINFOW>(&osInfo));
}
}
wsprintf(pszMajorMinorBuild, _T("%u.%u.%u"), osInfo.dwMajorVersion, osInfo.dwMinorVersion, osInfo.dwBuildNumber);
#ifdef UNICODE
lstrcpyW(pszServicePack, osInfo.szCSDVersion); // Wide string version
#else
wcstombs(pszServicePack, osInfo.szCSDVersion, 199); // Convert to ANSI
#endif
if (osInfo.dwMajorVersion == 10 && osInfo.dwBuildNumber >= 26100)
{
lstrcpy(pszVersion, _T("Windows 2025"));
*nVersion = 120; // Assigning a new version number for Windows 2025
}
else if (osInfo.dwMajorVersion == 10 && osInfo.dwBuildNumber >= 20348)
{
lstrcpy(pszVersion, _T("Windows 2022"));
*nVersion = 118; // Assigning a new version number for Windows 2022
}
else if (osInfo.dwMajorVersion == 10 && osInfo.dwBuildNumber >= 17763)
{
lstrcpy(pszVersion, _T("Windows 2019"));
*nVersion = 116; // Assigning a new version number for Windows 2019
}
else if (osInfo.dwMajorVersion == 10 && osInfo.dwBuildNumber >= 14393)
{
lstrcpy(pszVersion, _T("Windows 2016"));
*nVersion = 115; // Assigning a new version number for Windows 2016
}
else if (osInfo.dwMajorVersion == 6 && osInfo.dwBuildNumber >= 9600)
{
lstrcpy(pszVersion, _T("Windows 2012 R2"));
*nVersion = 111; // Assigning a new version number for Windows 2012 R2
}
else if (osInfo.dwMajorVersion == 10 && osInfo.dwBuildNumber >= 26100)
{
lstrcpy(pszVersion, W11STR);
*nVersion = W11;
}
else if (osInfo.dwMajorVersion == 10 && osInfo.dwBuildNumber >= 22631)
{
lstrcpy(pszVersion, W11STR);
*nVersion = W11;
}
else if (osInfo.dwMajorVersion == 10 && osInfo.dwBuildNumber >= 22621)
{
lstrcpy(pszVersion, W11STR);
*nVersion = W11;
}
else if (osInfo.dwMajorVersion == 10 && osInfo.dwBuildNumber >= 22000)
{
lstrcpy(pszVersion, W11STR);
*nVersion = W11;
}
else if (osInfo.dwMajorVersion == 10 && osInfo.dwBuildNumber >= 10240 && osInfo.dwBuildNumber <= 19045)
{
lstrcpy(pszVersion, W10STR);
*nVersion = W10;
}
else if (osInfo.dwMajorVersion == 6 && osInfo.dwMinorVersion == 3)
{
lstrcpy(pszVersion, W81STR);
*nVersion = W81;
}
else if (osInfo.dwMajorVersion == 6 && osInfo.dwMinorVersion == 2)
{
lstrcpy(pszVersion, W8STR);
*nVersion = W8;
}
else if (osInfo.dwMajorVersion == 6 && osInfo.dwMinorVersion == 1)
{
lstrcpy(pszVersion, W7STR);
*nVersion = W7;
}
else if (osInfo.dwMajorVersion == 6 && osInfo.dwMinorVersion == 0)
{
if (osInfo.wProductType == VER_NT_WORKSTATION)
{
lstrcpy(pszVersion, WVISTASTR);
*nVersion = WVISTA;
}
else
{
lstrcpy(pszVersion, WSVR2012STR);
*nVersion = WSVR2012;
}
}
else if (osInfo.dwMajorVersion == 5 && osInfo.dwMinorVersion == 1)
{
lstrcpy(pszVersion, WXPSTR);
*nVersion = WXP;
}
else if (osInfo.dwMajorVersion == 5 && osInfo.dwMinorVersion == 0)
{
lstrcpy(pszVersion, W2KSTR);
*nVersion = W2K;
}
return TRUE;
}