Detect OS Windows 8.1

I can’t get my program to recognise Windows 8.1.
I am using this code snippet from one of the posts on this forum but it recognizes for all OS except windows 8.1 which reportedly seems to show as Windows 10 for my customers.
Unfortunately I don’t have 8.1 installed anywhere to test. My experience with all things Windows 8 was unregrettably short :slight_smile:

#elseif TargetWin32
dim OS_CODE as Integer
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 )
info = New MemoryBlock( 148 )
info.Long( 0 ) = info.Size
GetVersionExA( info )
End If

Dim Str As String

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”
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
dim res as string = s.Result
if val(mid(res,30,2)) = 10 then
os = “Windows 10”
os = “Windows 8/8.1”
end if
End Select

Return os[/code]

GetVersionEx won’t work unless you have manifest telling your app works with 8.1, if I remember correctly.

Version functions in SystemInformationMBS module from us should detect it.
See SystemInformationMBS.isWindows81 function.

Interesting, the code I posted does actually work and detects Windows 8/8.1.
But only in the 32 bit version of the app. In the 64bit compile it doesn’t work.

#elseif TargetWin64 ?

No TargetWin32 returns True on both 32-bit and 64-bit windows.

Or you could read the version details from kernel32.dll

Here’s a program that’ll do that, comment line 1 and uncomment line 2 from pushbutton1.action in this example to see the version number returned from kernel32.dll

For example, my windows 8.1 machine returns 6.3.96000.17415

The code was written for someone else to get the lang-codepage out of a file, it happens to work for what you want also.

Tested on w10-64, w7-32 w8.1-32 w8.1-64 and they all seemed to work out ok.

Thanks I’ll try that.
I went the long way round and installed Windows 8.1 on a virtual machine to see what was happening
Came up with this:

    case 602 // 32bit Windows 8/8.1 and 10
      dim s as new shell
      dim res as string = s.Result
      if val(mid(res,30,2)) = 10 then
        os = "Windows 10"
        os = "Windows 8/8.1"
      end if
    case 603 // 64 bit Windows 8.1
      os = "Windows 8.1"
    case 1000 // 64 bit Windows 10
      os = "Windows 10"
    case else
      os = "Unknown Windows build - " + str(OS_CODE)
    End Select

Unfortunately couldn’t test 64bit Windows 8