title: Detecting Windows 11 properly
body: <p>I'm a developper from the FOSS game 0 A.D. (<a href="https://play0ad.com" rel="nofollow noreferrer">https://play0ad.com</a>) and I recently realised that our detection of the Windows version was failing for Windows 11, just like it did between Windows 8.1 and Windows 10.</p>
  <p>It reports Windows 10.0.22000 which is technically the correct version, but we'd like it to report Windows 11 instead.</p>
  <p>Here is the current code we use</p>
  <ul>
  <li><a href="https://github.com/0ad/0ad/blob/master/source/lib/sysdep/os/win/wposix/wutsname.cpp#L35" rel="nofollow noreferrer">https://github.com/0ad/0ad/blob/master/source/lib/sysdep/os/win/wposix/wutsname.cpp#L35</a></li>
  <li><a href="https://github.com/0ad/0ad/blob/master/source/lib/sysdep/os/win/wversion.cpp" rel="nofollow noreferrer">https://github.com/0ad/0ad/blob/master/source/lib/sysdep/os/win/wversion.cpp</a></li>
  <li><a href="https://github.com/0ad/0ad/blob/master/source/lib/sysdep/os/win/wversion.h" rel="nofollow noreferrer">https://github.com/0ad/0ad/blob/master/source/lib/sysdep/os/win/wversion.h</a></li>
  </ul>
  <p>We're stuck with the Windows 7 SDK for compatibility reasons.</p>
  <p>Easy solution would be to replace</p>
  <pre class="lang-cpp prettyprint-override"><code>    if (osInfo.dwMajorVersion &gt;= 10)
      {
          stream &lt;&lt; &quot;Win&quot; &lt;&lt; osInfo.dwMajorVersion;
      }
  </code></pre>
  <p>by</p>
  <pre class="lang-cpp prettyprint-override"><code>    if (osInfo.dwMajorVersion &gt;= 10)
      {
          if (osInfo.dwMinorVersion &gt; 22000)
              stream &lt;&lt; &quot;Win&quot; &lt;&lt; 11;
          else
              stream &lt;&lt; &quot;Win&quot; &lt;&lt; osInfo.dwMajorVersion;
      }
  </code></pre>
  <p>Is there a more robust/future proof solution.</p>
  <p>Thanks in advance!</p>