Hey Y'all,

I just came across an interesting problem. I have VBA code (2 Versions) to determine the version of Windows which is being run.
On my Win 8.1 Pro machine they do not agree!
Using Windows Management Instrumentation calls I get:
Win81Info.JPG

[code]
Option Explicit

Sub GetOS()

Dim objOS As Object
Dim Msg As String
Dim Msg1 As String

On Error Resume Next
' Connect to WMI and obtain instances of Win32_OperatingSystem
For Each objOS In GetObject("winmgmts:").InstancesOf("Win32_Operatin gSystem")
Msg = Msg & "Manufacturer = " & objOS.Manufacturer & vbCr '// string Manufacturer;
Msg = Msg & "Operating System = " & objOS.Caption & vbCr '// uint64 TotalSwapSpaceSize;
Msg = Msg & "Version = " & objOS.Version & vbCr '// string Version;
Msg = Msg & "BuildNumber = " & objOS.BuildNumber & vbCr
Msg = Msg & "CSDVersion = " & objOS.CSDVersion & vbCr
Msg = Msg & "ServicePackMajorVersion = " & objOS.ServicePackMajorVersion & vbCr '// uint16 ServicePackMajorVersion;
Msg = Msg & "ServicePackMinorVersion = " & objOS.ServicePackMinorVersion & vbCr '// uint16 ServicePackMinorVersion;
Msg = Msg & "Status = " & objOS.Status & vbCr '// string Status;
Msg = Msg & "Computer Name = " & objOS.CSName & vbCr
Msg = Msg & "InstallDate = " & WMIDateStringToDate(objOS.InstallDate) & vbCr '// datetime InstallDate;
Msg = Msg & "RegisteredUser = " & objOS.RegisteredUser & vbCr '// string RegisteredUser;
Msg = Msg & "SerialNumber = " & objOS.SerialNumber & vbCr '// string SerialNumber;
Msg = Msg & "OSType = " & strOsType(objOS.OSType) & vbCrLf '// uint16 OSType;
Msg = Msg & "Primary operating system= " & objOS.Primary & vbCr '// boolean Primary;
Msg = Msg & "OSLanguage = " & strOsLang(objOS.OSLanguage) & vbCr '// uint32 OSLanguage;

MsgBox Msg, vbOKOnly + vbInformation, "Windows Version Information:"

Next

If Err <> 0 Then MsgBox Err.Description

End Sub

Private Function WMIDateStringToDate(dtmInstallDate)

WMIDateStringToDate = CDate( _
Mid(dtmInstallDate, 5, 2) & "/" & _
Mid(dtmInstallDate, 7, 2) & "/" & _
Left(dtmInstallDate, 4) & " " & _
Mid(dtmInstallDate, 9, 2) & ":" & _
Mid(dtmInstallDate, 11, 2) & ":" & _
Mid(dtmInstallDate, 13, 2))

End Function


Private Function strOsType(intOs As Integer) As String

Select Case intOs
Case 14: strOsType = "MSDOS"
Case 15: strOsType = "WIN3x"
Case 16: strOsType = "WIN95"
Case 17: strOsType = "WIN98"
Case 18: strOsType = "WINNT"
Case 19: strOsType = "WINCE"
Case Else: strOsType = "Non-Windows"
End Select

End Function

Private Function strOsLang(intOsLang As Integer) As String
Select Case intOsLang
Case 9: strOsLang = " English "
Case 1033: strOsLang = " English "
Case Else: strOsLang = " Non-English "
End Select

End Function
[\code]
Using Windows OS calls I get:
Win81InfoGetVersionEx.JPG

Code:
Option Explicit

Type OSVERSIONINFO   '  148 Bytes
        dwOSVersionInfoSize As Long
        dwMajorVersion As Long
        dwMinorVersion As Long
        dwBuildNumber As Long
        dwPlatformId As Long
        szCSDVersion As String * 128
End Type

Declare Function GetVersionEx& Lib "kernel32" _
Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO)

Sub FindWindowsVersion2()

   Dim tOSVer As OSVERSIONINFO
   Dim bNT    As Boolean    '*** Is this a version of NT? ***
   Dim zOsVer As String
   Dim Msg    As String
   bNT = IIf(InStr(Application.OperatingSystem, "NT") = 0, False, True)
   
   tOSVer.dwOSVersionInfoSize = 148
   GetVersionEx& tOSVer
   
   With tOSVer
       Msg = "Using Windows Function GetVersionEx&" & vbCrLf & vbCrLf
       Msg = Msg & "Major Version = " & tOSVer.dwMajorVersion & vbCrLf '// string Major Version;
       Msg = Msg & "Minor Version = " & tOSVer.dwMinorVersion & vbCrLf '// string Minor Version;
       Msg = Msg & "BuildNumber = " & tOSVer.dwBuildNumber
   
    MsgBox Msg, vbOKOnly + vbInformation, "Windows Version Information:"

   End With
   
End Sub   'FindWindowsVersion2
In Windows 7 HP SP-1 both methods report the same information. Ver 6.1 Build 7601
In Windows 8.0 Pro both methods report the same information: Ver 6.2 Build 9200

FYI: Windows 8.1 was upgrade installed via an ISO image.

Any ideas why this is happening?

Here's the Excel file with the VBA code. Use Alt+F8 and run GetOs (this gives the correct data) and FindVersion2 (this gives the erroneous information.
VBA - Excel - Windows Version Info.xls
Note: The attachment is an .xls file for compatibility I tried saving it as an .xlsm file and it made no difference.