They say its fixed but

Heck I’ll post the code HERE so they can just lift it

Attributes( StructureAlignment = 1 ) Protected Structure OSVersionInfo
  major as integer
  minor as integer
  bug as integer
End Structure

this is in a module that has a few properties

Private Property m_Build As string
Private Property m_Bug As integer
Private Property m_cputype As string
Private Property m_MajorVersion As integer
Private Property m_MinorVersion As integer
Private Property m_Initialized As Boolean

The first time ANY method in the module tries to grab one of those properties its initialized

Private Sub Initialize()
  If m_Initialized Then 
    Return
  End If
  
  m_Initialized = True
  
  #If TargetMacOS
    
    // --- We're using 10.10
    Declare Function NSClassFromString Lib "AppKit" ( className As CFStringRef ) As Ptr
    Declare Function processInfo Lib "AppKit" Selector "processInfo" ( ClassRef As Ptr ) As Ptr
    Dim myInfo As Ptr = processInfo( NSClassFromString( "NSProcessInfo" ) )
    Declare Function operatingSystemVersion Lib "AppKit" Selector "operatingSystemVersion" ( NSProcessInfo As Ptr ) As OSVersionInfo
    Dim rvalue As OSVersionInfo = operatingSystemVersion( myInfo )
    
    m_MajorVersion = rValue.major
    m_MinorVersion = rvalue.minor
    m_Bug = rvalue.bug
    
    Declare Function sysctlbyname Lib "/usr/lib/libSystem.dylib" (name As cString, out As ptr, ByRef size As UInteger, newP As ptr, newPSize As UInteger) As Integer
    
    Dim size As UInteger = 128
    Dim mb As New memoryblock(size)
    
    If sysctlbyname( "kern.osversion", mb, size, Nil, 0 ) = 0 Then
      m_build = Trim(mb.CString(0))
    End If
    
    size = 256
    mb = New memoryblock(size)
    Dim retvalue As Integer = sysctlbyname( "machdep.cpu.brand_string", mb, size, Nil, 0 )
    If sysctlbyname( "machdep.cpu.brand_string", mb, size, Nil, 0 ) = 0 Then
      m_cputype = Trim(mb.CString(0))
    End If
    
  #ElseIf TargetWindows
    
    Dim m As MemoryBlock
    Dim wsuitemask As Integer
    Dim ret As Integer
    Dim szCSDVersion As String
    Dim s As String
    
    Soft Declare Function GetVersionExA Lib "kernel32" (lpVersionInformation As ptr) As Integer
    Soft Declare Function GetVersionExW Lib "kernel32" (lpVersionInformation As ptr) As Integer
    
    Dim retryUsingAVersion As Boolean = True
    
    If System.IsFunctionAvailable( "GetVersionExW", "Kernel32" ) Then
      
      retryUsingAVersion = False
      
      m = NewMemoryBlock(284) ''use this for osversioninfoex structure (2000+ only)
      m.long(0) = m.size 'must set size before calling getversionex 
      ret = GetVersionExW(m) 'if not 2000+, will return 0
      
      If ret = 0 Then
        // need to rety since 0 means "FAILED"
        m = NewMemoryBlock(276)
        m.long(0) = m.size 'must set size before calling getversionex 
        ret = GetVersionExW(m)
        
        If ret = 0 Then
          // Something really strange has happened, so use the A version
          // instead
          retryUsingAVersion = True
        End
      End
      
    End If
    
    If retryUsingAVersion = True Then
      m = NewMemoryBlock(156) ''use this for osversioninfoex structure (2000+ only)
      m.long(0) = m.size 'must set size before calling getversionex
      ret = GetVersionExA(m) 'if not 2000+, will return 0
      If ret = 0 Then
        m = NewMemoryBlock(148) ' 148 sum of the bytes included in the structure (long = 4bytes, etc.)
        m.long(0) = m.size 'must set size before calling getversionex
        ret = GetVersionExA(m)
        If ret = 0 Then
          Return
        End
      End
    End If
    
    m_MajorVersion = m.long(4)
    m_MinorVersion = m.long(8)
    m_Bug = m.long(12)
    
  #EndIf
  
End Sub

have at it

This is all in GitHub - npalardy/KitchenSink: A starter project that has piles of utilities and extensions for Xojo (one of everything including the kitchen sink)

Fun port is because there’s NO parsing whatsoever I’d guess this is LESS code than they have now !!!

3 Likes