Home > Backend Development > C++ > How Can I Detect the Windows OS Version Using .NET?

How Can I Detect the Windows OS Version Using .NET?

DDD
Release: 2025-01-15 21:28:44
Original
882 people have browsed it

How Can I Detect the Windows OS Version Using .NET?

Use .NET to detect Windows version

Question:

How to determine the Windows operating system version in a .NET application?

Answer:

To detect the Windows operating system version in .NET, you can use the System.Environment.OSVersion attribute. It provides the following information:

  • PlatformID: Indicates the underlying platform (e.g., Win32Windows, Win32NT)
  • Major Version: The major version number of Windows (for example, 4 for Windows 95, 6 for Windows Vista, 10 for Windows 10)
  • Minor Version: The minor version number of Windows (for example, 0 for Windows 95, 1 for Windows XP)

Specific Windows version and its OSVersion value:

<code>| Windows版本 | PlatformID | 主要版本 | 次要版本 |
|---|---|---|---|
| Windows 95 | Win32Windows | 4 | 0 |
| Windows 98 | Win32Windows | 4 | 10 |
| Windows Me | Win32Windows | 4 | 90 |
| Windows NT 4.0 | Win32NT | 4 | 0 |
| Windows 2000 | Win32NT | 5 | 0 |
| Windows XP | Win32NT | 5 | 1 |
| Windows 2003 | Win32NT | 5 | 2 |
| Windows Vista | Win32NT | 6 | 0 |
| Windows 2008 | Win32NT | 6 | 0 |
| Windows 7 | Win32NT | 6 | 1 |
| Windows 2008 R2 | Win32NT | 6 | 1 |
| Windows 8 | Win32NT | 6 | 2 |
| Windows 8.1 | Win32NT | 6 | 3 |
| Windows 10 | Win32NT | 10 | 0 |</code>
Copy after login

Note:

  • For a more complete understanding of the exact Windows version, use a library that provides this information.
  • Make sure your executable assembly manifest explicitly declares compatibility with Windows 8.1 and Windows 10.0 to avoid incorrect OSVersion values ​​for these versions.

The above is the detailed content of How Can I Detect the Windows OS Version Using .NET?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template