Vb.net 指定Windows版本。生成

Vb.net 指定Windows版本。生成,vb.net,windows,desktop-application,Vb.net,Windows,Desktop Application,我无法找到正确的表单来告诉我的应用程序根据windows build在文本框中写入不同的内容 代码是: Private Sub Main_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load Dim OSVer As Version = Environment.OSVersion.Version 'Windows 10 If OSVer.Build >= 10240 Then

我无法找到正确的表单来告诉我的应用程序根据windows build在文本框中写入不同的内容

代码是:

Private Sub Main_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load

Dim OSVer As Version = Environment.OSVersion.Version

    'Windows 10
    If OSVer.Build >= 10240 Then
        My.Forms.Main.WinVer.Text = "Detected Windows 10"
    End If

    'Windows 8 / 8.1
    If OSVer.Build <= 10000 And OSVer.Build >= 8000 Then
        My.Forms.Main.WinVer.Text = "Windows 8 / 8.1 are not supported yet"
    End If

    'Windows 7
    If OSVer.Build >= 7600 And OSVer.Build < 8000 Then
        My.Forms.Main.WinVer.Text = "Detected Windows 7"
    End If

    'OLD WINDOWS VERSION
    If OSVer.Build < 7600 Then
        My.Forms.Main.WinVer.Text = "Your Windows is not supported"
    End If
End Sub
Private Sub-Main_Load(ByVal sender作为对象,ByVal e作为事件参数)处理MyBase.Load
Dim OSVer As Version=Environment.OSVersion.Version
“Windows 10
如果OSVer.Build>=10240,则
My.Forms.Main.WinVer.Text=“检测到Windows 10”
如果结束
'Windows 8/8.1
如果OSVer.Build=8000,则
My.Forms.Main.WinVer.Text=“尚不支持Windows 8/8.1”
如果结束
“Windows 7
如果OSVer.Build>=7600且OSVer.Build<8000,则
My.Forms.Main.WinVer.Text=“检测到Windows 7”
如果结束
'旧WINDOWS版本
如果OSVer.Build小于7600,则
My.Forms.Main.WinVer.Text=“不支持您的Windows”
如果结束
端接头
我在windows 10(build 10240)上,使用此代码后,应用程序向我显示了windows 8/8.1的文本

如何更正此问题?

根据,您必须正确定位应用程序以获得预期结果


正确设置清单后,可以使用
OSVersion.Version.Major
OSVersion.Version.Minor
属性检查操作系统。上述文章中以表格形式指定了版本号。

更多信息:-Windows 10 Pro(build 10240)-Visual Studio 2015社区-语言:VB.NETCode看起来不错,OSVer.build的值是多少?当您单步执行此代码时,请查看它是否正确,Microsoft不希望您告诉客户您的程序在Windows 10上运行不正确。他们已经做了很多工作来确保你的程序在Win10上运行正常。他们曾经花费大量时间为这些版本测试创建appcompat垫片,现在不再是了。如果您不想支持Win10,那么您需要在系统需求中说明这一点。否则,它们无法阻止您在操作系统可执行文件(如kernel32)上使用FileVersionInfo。dll@Eric我的操作系统是windows 10(10240)因此,根据这段代码,我必须获得输出
检测到的Windows 10
,但它给了我
不支持Windows 8/8.1
哇,我发现一切都是正确的,但当我从debug Folder启动应用程序时,可能是与构建配置有关