Question: How do I identify the Windows OS version in my .NET application?
Answer:
TheSystem.Environment.OSVersion
attribute provides information to differentiate between major Windows operating system versions, but may not be sufficient for all versions. It contains three components corresponding to the following Windows versions:
平台 ID | 主版本 | 次版本 |
---|---|---|
Win32Windows | 4 | 0 |
Win32Windows | 4 | 10 |
Win32Windows | 4 | 90 |
Win32NT | 4 | 0 |
Win32NT | 5 | 0 |
Win32NT | 5 | 1 |
Win32NT | 5 | 2 |
Win32NT | 6 | 0 |
Win32NT | 6 | 0 |
Win32NT | 6 | 1 |
Win32NT | 6 | 1 |
Win32NT | 6 | 2 |
Win32NT | 6 | 3 |
Win32NT | 10 | 0 |
To more accurately determine your specific Windows version, consider using the following libraries: Library Links
Important Note:
Your assembly manifest must explicitly state that your executable assembly is compatible with Windows 8.1 and Windows 10.0 to avoid getting Windows 8 version (6.2) instead of 6.3 or 10.0. (Source: Source link )
Updates for .NET 5.0 and above:
In .NET 5.0 and later, the System.Environment.OSVersion
property always returns the actual operating system version. For more information, see Microsoft Documentation Link.
The above is the detailed content of How Can I Reliably Detect Windows OS Versions in My .NET Application?. For more information, please follow other related articles on the PHP Chinese website!