How can we check if the current OS is win8 or blue

蓝咒 提交于 2019-12-17 16:44:18

问题


Win8.1 and Win8 has the same OS Version. How can we check if the current OS is Win8 or Blue? The Environment.OSVersion is giving us the same results:

Environment.OSVersion 6.2.9200.0 Environment.OSVersion.Version 6.2.9200.0 Environment.OSVersion.Version.Major 6 Environment.OSVersion.Version.Minor 2


回答1:


Windows 8.1 will lie to you and tell you it is Window 8. Changing that lie requires editing the manifest that is embedded in your program so that Windows knows you don't want to be lied to. Project + Add New Item, select the Application Manifest File item template. Copy paste this verbiage underneath the <application> element:

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> 
    <application> 
        <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
    </application> 
</compatibility>



回答2:


I found a solution under this Registry Key

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion



回答3:


Since I wasn't able to get Hans' solution working, I created a different solution:

bool _IsWindows8Point1OrGreater = Type.GetType("Windows.UI.Xaml.Controls.Flyout, Windows.UI.Xaml, ContentType=WindowsRuntime", false) != null;



回答4:


In case of Win8.1 the version is 6.3.*

http://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx

If you are using GetVersionEx() api [from kernel32.dll] for getting Win8.1 version, the value returned will be 6.2.* whereas the version value should be 6.3.*

The solution to this is either you need to add assembly manifest to the .net exe or os.dll to state that symhelp will run on windows 8.1, that might make the .net System.Environment.OSVersion.Version function correctly.

However you need to test it on multiple OS's.

http://msdn.microsoft.com/en-us/library/windows/desktop/dn302074(v=vs.85).aspx

http://msdn.microsoft.com/en-us/library/windows/desktop/ms724429(v=vs.85).aspx



来源:https://stackoverflow.com/questions/17406850/how-can-we-check-if-the-current-os-is-win8-or-blue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!