fix: #52 Can't identify Windows 11
This commit is contained in:
@@ -5,6 +5,24 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
#include <NTSecAPI.h>
|
||||||
|
|
||||||
|
// by ChatGPT
|
||||||
|
bool IsWindows11() {
|
||||||
|
typedef NTSTATUS(WINAPI* RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);
|
||||||
|
RTL_OSVERSIONINFOW rovi = { 0 };
|
||||||
|
rovi.dwOSVersionInfoSize = sizeof(rovi);
|
||||||
|
|
||||||
|
HMODULE hMod = GetModuleHandleW(L"ntdll.dll");
|
||||||
|
if (hMod) {
|
||||||
|
RtlGetVersionPtr rtlGetVersion = (RtlGetVersionPtr)GetProcAddress(hMod, "RtlGetVersion");
|
||||||
|
if (rtlGetVersion) {
|
||||||
|
rtlGetVersion(&rovi);
|
||||||
|
return (rovi.dwMajorVersion == 10 && rovi.dwMinorVersion == 0 && rovi.dwBuildNumber >= 22000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
---------------------
|
---------------------
|
||||||
@@ -24,6 +42,11 @@ std::string getSystemName()
|
|||||||
{
|
{
|
||||||
return vname;
|
return vname;
|
||||||
}
|
}
|
||||||
|
if (IsWindows11()) {
|
||||||
|
vname = "Windows 11";
|
||||||
|
printf_s("<EFBFBD>˵<EFBFBD><EFBFBD>Եİ汾Ϊ:%s\n", vname.c_str());
|
||||||
|
return vname;
|
||||||
|
}
|
||||||
DWORD dwMajor, dwMinor, dwBuildNumber;
|
DWORD dwMajor, dwMinor, dwBuildNumber;
|
||||||
NTPROC proc = (NTPROC)GetProcAddress(hinst, "RtlGetNtVersionNumbers");
|
NTPROC proc = (NTPROC)GetProcAddress(hinst, "RtlGetNtVersionNumbers");
|
||||||
if (proc==NULL)
|
if (proc==NULL)
|
||||||
|
|||||||
Reference in New Issue
Block a user