get windows version – 2

  MAP
    ReFlex__OS(BYTE Extended=0),BYTE
    MODULE('')
      GetVersionEx(LONG),SIGNED,PASCAL,NAME('GetVersionExA'),PROC
    END
  END
  
ReFlex__OS FUNCTION(BYTE Extended=0)
!
! If NOT "Extended"   return 0 = Win9x/ME, 1 = NT, 2 = W2K/Whistler(XP)
! If "Extended"       return 1 = Win95, 2 = Win98, 3 = NT3.51, 4 = NT4, 5 = W2K, 6 = ME, 7 = Whistler(XP)
! Returns 255 on error
!

OSVersionInfo       GROUP,PRE()
InfoSize              ULONG
MajorVersion          ULONG
MinorVersion          ULONG
BuildNumber           ULONG
PlatformID            ULONG
CSDVersion            STRING(128)
                    END

  !   OS          MajorVersion  MinorVersion  PlatformID
  ! =====================================================
  !  Win95             4             0            1
  !  Win98             4            >0            1
  !  ME                4            90            1
  !  NT3.51            3            51            2
  !  NT4               4             0            2
  !  W2K               5             0            2
  !  Whistler(XP)      5             1            2

  CODE
  CLEAR(OSVersionInfo)
  InfoSize = SIZE(OSVersionInfo)
  IF NOT GetVersionEx(ADDRESS(OSVersionInfo)) THEN RETURN(255).

  IF NOT Extended
    RETURN( CHOOSE(PlatformID = 1, 0, CHOOSE(PlatformID = 2, CHOOSE(MajorVersion < 5, 1, 2), 255)) )
  ELSE
    IF MajorVersion = 4 AND MinorVersion = 90
      RETURN(6)
    ELSIF MajorVersion = 5 AND MinorVersion = 1
      RETURN(7)
    END
    RETURN( CHOOSE(PlatformID = 1, CHOOSE(MinorVersion = 0, 1, 2), CHOOSE(PlatformID = 2, MajorVersion, 255)) )
  END

Schreibe einen Kommentar