Hello @Anderson Rodrigues Cavalcante ,
Welcome to Microsoft Q&A!
It is recommended to use Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamilyVersion, you can get OS build information from it.
The OS build of Win11 starts from 22000. If the build is smaller than 22000, it can determine that the current OS is Win10.
string deviceFamilyVersion = Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamilyVersion;
ulong version = ulong.Parse(deviceFamilyVersion);
ulong major = (version & 0xFFFF000000000000L) >> 48;
ulong minor = (version & 0x0000FFFF00000000L) >> 32;
ulong build = (version & 0x00000000FFFF0000L) >> 16;
ulong revision = (version & 0x000000000000FFFFL);
var osVersion = $"{major}.{minor}.{build}.{revision}";
if (build >= 22000)
{
Debug.WriteLine("win11");
}
else
{
Debug.WriteLine("win10");
}
Thank you.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 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.