我正在尝试确定 .NET 应用程序中的操作系统版本,该应用程序已使用 System.Environment.OSVersion 成功确定 Windows 8.1 之前所有版本的 Windows 的版本。
但是,在 Windows 10 上的 .NET 应用程序中调用 System.Environment.OSVersion
时,返回的版本是 Microsoft Windows NT 6.2.9200.0
(这正是与 Windows 8.1 上的输出相同)。但是,当通过 PowerShell 调用 [System.Environment]::OSVersion
时,输出为我 Microsoft Windows NT 10.0.10240.0
。
我的印象是 PowerShell 在幕后使用 .NET 并期望这两个调用返回完全相同的输出。为什么输出存在差异,更重要的是,我如何检测我的应用程序是否在 Windows 10 上运行?
最佳答案
我认为this is the cause :
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).
关于c# - .NET 应用程序将不同的操作系统版本返回到 Windows 10 上的 PowerShell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32121110/