.NET 应用程序在 Windows 10 上向 PowerShell 返回不同的 OS 版本
.NET app returning different OS version to PowerShell on Windows 10
我正在尝试确定 .NET 应用程序中的 OS 版本,该应用程序已经使用 System.Environment.OSVersion 来成功确定 Windows 所有版本的版本,直到 [=23] =] 8.1.
但是,当在 Windows 10 上的 .NET 应用程序中调用 System.Environment.OSVersion
时,版本 returned 是 Microsoft Windows NT 6.2.9200.0
(与上的输出完全相同Windows8.1)。但是,当通过 PowerShell 调用 [System.Environment]::OSVersion
时,输出为我 Microsoft Windows NT 10.0.10240.0
.
我的印象是 PowerShell 在幕后使用 .NET 并期望对 return 的两次调用都具有完全相同的输出。为什么输出存在差异,更重要的是,我如何检测我的应用程序是否在 Windows 10 上 运行?
With the release of Windows 8.1, the behavior of the GetVersion
API has changed in the value it will return for the operating system version. The value returned by the GetVersion function now depends on how the application is manifested.
Applications not manifested for Windows 8.1 or Windows 10 will return the Windows 8 OS version value (6.2).
我正在尝试确定 .NET 应用程序中的 OS 版本,该应用程序已经使用 System.Environment.OSVersion 来成功确定 Windows 所有版本的版本,直到 [=23] =] 8.1.
但是,当在 Windows 10 上的 .NET 应用程序中调用 System.Environment.OSVersion
时,版本 returned 是 Microsoft Windows NT 6.2.9200.0
(与上的输出完全相同Windows8.1)。但是,当通过 PowerShell 调用 [System.Environment]::OSVersion
时,输出为我 Microsoft Windows NT 10.0.10240.0
.
我的印象是 PowerShell 在幕后使用 .NET 并期望对 return 的两次调用都具有完全相同的输出。为什么输出存在差异,更重要的是,我如何检测我的应用程序是否在 Windows 10 上 运行?
With the release of Windows 8.1, the behavior of the
GetVersion
API has changed in the value it will return for the operating system version. The value returned by the GetVersion function now depends on how the application is manifested.Applications not manifested for Windows 8.1 or Windows 10 will return the Windows 8 OS version value (6.2).