question

PaulGafa-1577 avatar image
0 Votes"
PaulGafa-1577 asked Castorix31 commented

supportedOS ID for windows 11

https://docs.microsoft.com/en-us/windows/win32/sysinfo/targeting-your-application-at-windows-8-1

How can I detect windows 11 from a desktop application. I found no ID for it.

windows-11
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Windows 11 is new and APIs and other developer references hasn't been released yet.
Are you planning to do it in a .NET application?

0 Votes 0 ·
JennyFeng-MSFT avatar image
0 Votes"
JennyFeng-MSFT answered NageswaraRaoY-8639 commented

@PaulGafa-1577
Hi,
Since Windows 11 is newly released, there seems to be no relevant information at the moment.

============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread

· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thats exactly the point. Hope some information is shared soon.

0 Votes 0 ·

@PaulGafa-1577
Hi,
While there is no relevant information at this time, I will watching closely to this.
If there is any related update, we will let you know.

0 Votes 0 ·

appreciate the help, thanks

0 Votes 0 ·
Show more comments
Castorix31 avatar image
0 Votes"
Castorix31 answered PaulGafa-1577 commented

I don't have Windows 11, but maybe you can try the methods used on Windows 10 :

  • By reading values at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion
    (MS apps like Winver do that)


  • With RtlGetVersion :

         HMODULE hDll = LoadLibrary(TEXT("Ntdll.dll"));
         typedef NTSTATUS(CALLBACK* RTLGETVERSION) (PRTL_OSVERSIONINFOW lpVersionInformation);
         RTLGETVERSION pRtlGetVersion;
         pRtlGetVersion = (RTLGETVERSION)GetProcAddress(hDll, "RtlGetVersion");
         if (pRtlGetVersion)
         {
             RTL_OSVERSIONINFOW ovi = { 0 };
             ovi.dwOSVersionInfoSize = sizeof(ovi);
             NTSTATUS ntStatus = pRtlGetVersion(&ovi);
             if (ntStatus == 0)
             {
                 TCHAR wsBuffer[512];
                 wsprintf(wsBuffer, TEXT("Major Version : %d - Minor Version : %d - Build Number : %d\r\n"), ovi.dwMajorVersion, ovi.dwMinorVersion, ovi.dwBuildNumber);
                 OutputDebugString(wsBuffer);
             }
         }
    



· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Good suggestion, but unfortunately those APIs and registry locations don't provide much to identify Windows 11 as of 22000.100. Major and Minor is 10.0 which is the same as Windows 10.

Build number 22000 is being used for the current iterations of the Windows 11 Insider Builds, but assuming Windows 11 is build >= 22000 seems problematic. Windows 10 Dev Insider builds are already using builds in the 21000s and the ranges of builds may have some overlap between Windows 10 and Windows 11 unless Microsoft says otherwise.

In HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion there are some things you could try to use to distinguish between Windows 10 and 11 but it seems this area is also a work in progress. The key "ProductName" is reported as "Windows 10 Pro" on my Windows 11 Pro 22000.100 test system.

The only solution I've found that isn't geared for UWP apps is to query the WMI Win32_OperatingSystem object and parse the 'Name' field from the object. WMI is pretty heavy weight from my experience compared to reading a registry key, or using something like the version helpers (https://docs.microsoft.com/en-us/windows/win32/api/versionhelpers/nf-versionhelpers-iswindows10orgreater). WMI in Win32 is also just a pain to work with.

A lot companies are going to have to update their software prior to the Windows 11 launch. I hope more information is released on this soon as identification of the OS is required for some business use cases.

0 Votes 0 ·
PaulGafa-1577 avatar image PaulGafa-1577 randomhiker27-2113 ·

At the moment I am using the build number. An other alternative is to check if GetTmpPath2 exisits which till now it is not on windows 10.

0 Votes 0 ·
triendlkj-9495 avatar image
0 Votes"
triendlkj-9495 answered Castorix31 commented

It might be worth giving sysinternal's procmon utility a try, and see e.g. which registry values winver.exe reads.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Winver reads HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion

0 Votes 0 ·