MFCでWin10以上かどうかのチェック関数

BOOL IsWindows10OrGreater()
{
    HMODULE hNtdll = GetModuleHandleW(L"ntdll.dll");
    if (!hNtdll)
        return FALSE;

    typedef void (WINAPI *RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);
    RtlGetVersionPtr RtlGetVersion = (RtlGetVersionPtr)GetProcAddress(hNtdll, "RtlGetVersion");
    
    if (!RtlGetVersion)
        return FALSE;

    RTL_OSVERSIONINFOW osvi = { 0 };
    osvi.dwOSVersionInfoSize = sizeof(osvi);
    RtlGetVersion(&osvi);

    return (osvi.dwMajorVersion >= 10);
}