For whatever reason, Windows 10 shows as 602, build 9200. Which means it is not possible to distinguish 8, 8.1 and 10 by your method.
The best I found is to shell to Ver, which value is for Windows 10.
Microsoft Windows [Version 10.0.10240]
First number is 10, obviously, and the last digits are the build.
So basically something like this would do :
[code]Function WhichSystem() As String
Dim noerror As Boolean
Dim result As Integer
Dim sver As String
Dim sversion As String
Dim os As String
#If TargetMacOS
noerror=System.Gestalt(“sysv”,result)
If noerror Then
sver=Hex(result)
sversion=sver.Left(2) + “.” + sver.Mid(3,1) + “.” + sver.Right(1)
OS_CODE=Val(sver.Mid(3,1))
Select Case OS_CODE
Case 0
os="Cheetah"
Case 1
os="Puma"
Case 2
os="Jaguar"
Case 3
os="Panther"
Case 4
os="Tiger"
Case 5
os="Leopard"
Case 6
os="Snow Leopard"
Case 7
os="Lion"
Case 8
os="Mountain Lion"
Case Else
os="Unknown"
End Select
Return "Mac OSX "+os+" "+sversion
Else
Return ""
End If
#ElseIf TargetWin32
OS = "Windows"
//try to be more specific of windows version
Soft Declare Sub GetVersionExA Lib "Kernel32" ( info As Ptr )
Soft Declare Sub GetVersionExW Lib "Kernel32" ( info As Ptr )
Dim info As MemoryBlock
If System.IsFunctionAvailable( "GetVersionExW", "Kernel32" ) Then
info = New MemoryBlock( 20 + (2 * 128) )
info.Long( 0 ) = info.Size
GetVersionExW( info )
Else
info = New MemoryBlock( 148 )
info.Long( 0 ) = info.Size
GetVersionExA( info )
End If
Dim Str As String
Dim OS_CODE as Integer
OS_CODE=info.Long(4)*100+info.long(8)
Select Case OS_CODE
Case 400
os = "Windows 95/NT 4.0"
Case 410
os = "Windows 98"
Case 490
os = "Windows Me"
Case 300 To 399
os = "Windows NT 3.51"
OS_CODE=30
Case 500
os = "Windows 2000"
Case 501
os = "Windows XP"
Case 502
os = "Windows Server 2003"
Case 600
os = "Windows Vista"
Case 601
os = "Windows 7"
Case 602
dim s as new shell
s.execute("ver")
dim res as string = s.Result
if val(mid(res,30,2)) = 10 then
os = "Windows 10"
dim build as double = val(mid(res,33,10))*100000
Str = " Build "+format(build,"00000")
else
os = "Windows 8/8.1"
end if
End Select
if Str = "" then Str = " Build " + Str( info.Long( 12 ) )
If System.IsFunctionAvailable( "GetVersionExW", "Kernel32" ) Then
Str = Str + " " + Trim( info.WString( 20 ) )
Else
Str = Str + " " + Trim( info.CString( 20 ) )
End If
os = os + Str
Return os
#EndIf
End Function
[/code]
I tested it with Windows 10 and Windows 8.1. Since Windows 8 and 8.1 have exactly the same results with Dave method and Ver, I do not know how to discriminate them.