Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

1.5K
Vistas
Detect Windows 11 with .NET Framework or Windows API

In .NET Framework, to get the OS version you can use Environment.OSVersion with the Major and Minor values telling you the version of Windows (i.e 6.1 = Windows 7, 10.0 = Windows 10). Even though Windows 11 has been released (dev and beta channels) for over a month now, the documentation has not been updated to mention how to detect Windows 11.

For Windows API, GetVersion has been deprecated forever and even the version helper APIs only go up to IsWindows10OrGreater. Is there a simple check to figure out the major Windows version, in particular Windows 11? Someone had a similar question but for Delphi (How to detect Windows 11 using Delphi 10.3.3) and the accepted answer was all hacks. Why the hell is it so difficult for Microsoft to provide a simple API to just return the current system version? GetVersion should never have been deprecated.

over 4 years ago · Santiago Trujillo
4 Respuestas
Responde la pregunta

0

This most likely isn't perfect, but it's a workaround I've been using for a bit:

Environment.OSVersion.Version.Build >= 22000;

Windows 11 starts at build number 22000 and Windows 10 ends roughly at build number 21390, so this will only detect Windows 11 builds as far as I'm aware.

Do check whether it even is a Windows system in the first place though, another OS might have a higher build number.

over 4 years ago · Santiago Trujillo Denunciar

0

You can use RtlGetVersion() in ntdll.dll, which is not subject to OS compatibility manifestation, like GetVersion/Ex() and other similar APIs are (and especially since there is no supportedOS GUID defined for Windows 11 yet).

over 4 years ago · Santiago Trujillo Denunciar

0

RtlGetVersion() gave same results for Windows 10 and 11 as for me. I called it from the C# code as described here https://stackoverflow.com/a/49641055. I tried the Caption property of the WMI's Win32_OperatingSystem class.

using (var objOS = new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem"))
{
    foreach (ManagementObject objMgmt in objOS.Get())
    {
        Console.WriteLine("{0}: {1}", objMgmt.Properties["Caption"].Name, objMgmt.Properties["Caption"].Value);
    }
}

For Windows 10 I got "Microsoft Windows 10 Enterprise" and for Windows 11 "Microsoft Windows 11 Pro". Probably you could use the Name property but it contains excessive information like Windows folder and system drive or something like that.

over 4 years ago · Santiago Trujillo Denunciar

0

Use this code:

public static bool IsWindows11()
{
    var reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion");

    var currentBuildStr = (string)reg.GetValue("CurrentBuild");
    var currentBuild = int.Parse(currentBuildStr);

    return currentBuild >= 22000;
}

This is based on my findings on HKLM\Software\Microsoft\Windows NT\CurrentVersion: What's the difference between CurrentBuild and CurrentBuildNumber?

And note that this code can throw exceptions in case that the registry key does not exist or in case the value is not number. This should not happen in a normal system. But if you want to be safe, you can warp it in a try-catch block.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda