Author Topic: Support Windows Server 2019 and 2022 with OSVersion  (Read 613 times)

Quin

  • Sr. Member
  • ****
  • Posts: 299
    • View Profile
    • Quin's site
Support Windows Server 2019 and 2022 with OSVersion
« on: July 18, 2024, 12:57:50 PM »
I was scrolling through bc.bas today, and noticed that OSVersion seemingly only supports up to Windows Server 2016. There have been two major releases since then, 2019 and 2022. I originally wanted to submit a patch for this, but that code still goes a little too far over my head, so on the wishlist it goes for now  ;D

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 2538
    • View Profile
Re: Support Windows Server 2019 and 2022 with OSVersion
« Reply #1 on: July 18, 2024, 04:59:20 PM »
I was scrolling through bc.bas today, and noticed that OSVersion seemingly only supports up to Windows Server 2016. There have been two major releases since then, 2019 and 2022. I originally wanted to submit a patch for this, but that code still goes a little too far over my head, so on the wishlist it goes for now  ;D

I have no way to test this but ChatGPT provided the following additions which I will include in the next version:

Code: [Select]

    FPRINT FP_WRITE, "  case VER_PLATFORM_WIN32_NT:"
    FPRINT FP_WRITE, ""
    FPRINT FP_WRITE, "    if (osvi.dwMajorVersion==10 && osvi.dwMinorVersion==0)"
    FPRINT FP_WRITE, "    {"
    FPRINT FP_WRITE, "      if (osvi.dwBuildNumber >= 22000)                       return  OS_Win_11;"
    FPRINT FP_WRITE, "      if (osvi.wProductType == VER_NT_WORKSTATION)           return  OS_Win_10;"
    FPRINT FP_WRITE, "      if (osvi.dwBuildNumber >= 17763 && osvi.dwBuildNumber < 19041) return OS_Server_2019;"
    FPRINT FP_WRITE, "      if (osvi.dwBuildNumber >= 20348)                       return  OS_Server_2022;"
    FPRINT FP_WRITE, "      return  OS_Server_2016;"
    FPRINT FP_WRITE, "    }"



Quin

  • Sr. Member
  • ****
  • Posts: 299
    • View Profile
    • Quin's site
Re: Support Windows Server 2019 and 2022 with OSVersion
« Reply #2 on: July 18, 2024, 06:07:22 PM »
Seems good to me, thanks Kevin/ChatGPT  :)

airr

  • Sr. Member
  • ****
  • Posts: 265
    • View Profile
Re: Support Windows Server 2019 and 2022 with OSVersion
« Reply #3 on: July 20, 2024, 09:08:40 AM »
Two things:

1 - Windows Server 2019 has a build number of 17763, so the range in the example is not necessary.

2 - VER_NT_WORKSTATION can be multiple versions of Desktop Windows (Vista, 7, 8, and 10), per https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-osversioninfow#members

AIR.

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 2538
    • View Profile
Re: Support Windows Server 2019 and 2022 with OSVersion
« Reply #4 on: July 20, 2024, 12:19:43 PM »
Two things:

1 - Windows Server 2019 has a build number of 17763, so the range in the example is not necessary.

2 - VER_NT_WORKSTATION can be multiple versions of Desktop Windows (Vista, 7, 8, and 10), per https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-osversioninfow#members

AIR.

Thanks ... I've addressed No. 1 but have no comments ATM on No. 2.