我应该在C#程序中使用.NET Framework 3.5检测Windows 8.1的正确操作系统版本?(What should I do in my C# program to detect the

编程入门 行业动态 更新时间:2024-10-25 12:27:16
我应该在C#程序中使用.NET Framework 3.5检测Windows 8.1的正确操作系统版本?(What should I do in my C# program to detect the correct OS version for Windows 8.1, using .NET Framework 3.5?)

针对.NET Framework 3.5的我的C#程序无法检测到Windows 8.1操作系统的正确版本:当6.3.9600是正确值时,将返回6.2.9200。

Console.WriteLine(System.Environment.OSVersion.Version); // prints out 6.2.9200

我找到了这个帖子什么是Windows 8.1的操作系统版本? 提到了目前被打破的链接。

我该怎么做才能获得正确的价值?

My C# program, targeting .NET Framework 3.5 is unable to detect the correct version for Windows 8.1 OS: 6.2.9200 is returned when 6.3.9600 is the correct value.

Console.WriteLine(System.Environment.OSVersion.Version); // prints out 6.2.9200

I found this thread What is the OS version for Windows 8.1? which mentions a link that is currently broken.

What should I do to the program to obtain the correct value?

最满意答案

添加自定义应用程序清单(右键单击可执行项目 - >添加 - >新项目... - >查找应用程序清单文件)并在其compatibility部分中取消注释元素:

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> <application> <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> </application> </compatibility>

Add custom application manifest (right click executable project -> add -> new item... -> find application manifest file) and uncomment elements in its compatibility section:

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> <application> <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> </application> </compatibility>

更多推荐

本文发布于:2023-08-07 23:35:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1466400.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:操作系统   正确   版本   程序   Windows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!