My Own OS Version test [Win Only]

Share your advanced PureBasic knowledge/code with the community.
Axolotl
Enthusiast
Enthusiast
Posts: 798
Joined: Wed Dec 31, 2008 3:36 pm

My Own OS Version test [Win Only]

Post by Axolotl »

I was intrigued by some of the posts and had a look on my computer to see what I use here.
Since the two windows commands winver and ver produced different results, i dug a little deeper.

Here is what I found out, maybe it is useful for one or the other... (Not everyone is always up to date with the latest PB version).

First a quote from MSDN:
Identifying the current operating system is usually not the best way to determine whether a particular operating system feature is present. This is because the operating system may have had new features added in a redistributable DLL. Rather than using GetVersionEx to determine the operating system platform or version number, test for the presence of the feature itself.


You can check if the app is on a server with this...

Code: Select all

Import "kernel32.lib"
  IsWindowsServer() 
EndImport 
CompilerIf #PB_Compiler_IsMainFile 
  Debug "  Server OS ==> " + StringField("NO.YES.", 1+IsWindowsServer(), ".") 
CompilerEndIf 
And to get a (more accurate) version result, I built this.....

Code: Select all

Global NewMap OSVersionDetails.s() 
; initialize OSVersionDetails() with data from above list (even more on wikipedia and other sites) 
;
; Real WIN 11 
OSVersionDetails("26100") = "Windows 11 (24H2)"
OSVersionDetails("22631") = "Windows 11 (23H2)"
OSVersionDetails("22621") = "Windows 11 (22H2)"
OSVersionDetails("22000") = "Windows 11 (21H2)"
; Real WIN 10 
OSVersionDetails("19044") = "Windows 10 (21H2)"
OSVersionDetails("19043") = "Windows 10 (21H1)"
OSVersionDetails("19042") = "Windows 10 (20H2)"
OSVersionDetails("19041") = "Windows 10 (2004)"
OSVersionDetails("18363") = "Windows 10 (1909)"
OSVersionDetails("18362") = "Windows 10 (1903)"
OSVersionDetails("17763") = "Windows 10 (1809)"
OSVersionDetails("17134") = "Windows 10 (1803)"
OSVersionDetails("16299") = "Windows 10 (1709)"
OSVersionDetails("15063") = "Windows 10 (1703)"
OSVersionDetails("14393") = "Windows 10 (1607)"
OSVersionDetails("10586") = "Windows 10 (1511)"
OSVersionDetails("10240") = "Windows 10"
; tbc. 
; WIN 8 and older ???? 

; ---------------------------------------------------------------------------------------------------------------------

Procedure.s GetOSVersionName() 
  Protected result.s, NP, text.s, stdout.s, strleft.s, lenleft   

  ; INPUT : > ver 
  ; OUTPUT: Microsoft Windows [Version 10.0.22631.5039]
  ;
  NP = RunProgram("cmd.exe", "/C ver", "", #PB_Program_Open|#PB_Program_Read|#PB_Program_Hide) 
  If NP
    strleft = "Microsoft Windows [Version "     ; <-- look for this 
    lenleft = Len(strleft)                      ; <-- number of chars 
    While ProgramRunning(NP)
      If AvailableProgramOutput(NP)
        stdout = ReadProgramString(NP) 
        If Left(stdout, lenleft) = strleft 
          text = StringField(Mid(stdout, lenleft+1), 3, ".")  ; extract important Version Number Part 
          If text ; is valid 
            result = OSVersionDetails(text) 
            If result = "" 
              result = "Unknown: Build Number == " + text 
            EndIf 
          Else 
            result = "Syntax Issues: " + stdout 
          EndIf 
        EndIf 
      EndIf
    Wend
    CloseProgram(NP)                            ; Close the connection to the program
  EndIf

  ProcedureReturn result 
EndProcedure 

CompilerIf #PB_Compiler_IsMainFile 
  Debug "  OS Name: " + GetOSVersionName() 
CompilerEndIf 
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
Quin
Addict
Addict
Posts: 1122
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: My Own OS Version test [Win Only]

Post by Quin »

It works here, very nice! Thanks for sharing!
User avatar
DeanH
Enthusiast
Enthusiast
Posts: 274
Joined: Wed May 07, 2008 4:57 am
Location: Adelaide, South Australia
Contact:

Re: My Own OS Version test [Win Only]

Post by DeanH »

I got build 19045 on my Win 10 system, so have added the line

Code: Select all

OSVersionDetails("19045") = "Windows 10 (22H2)"
User avatar
DeanH
Enthusiast
Enthusiast
Posts: 274
Joined: Wed May 07, 2008 4:57 am
Location: Adelaide, South Australia
Contact:

Re: My Own OS Version test [Win Only]

Post by DeanH »

https://en.wikipedia.org/wiki/List_of_M ... _versions

From that I worked out:
OSVersionDetails("9600") = "Windows 8.1"
OSVersionDetails("9200") = "Windows 8"
OSVersionDetails("7601") = "Windows 7"
OSVersionDetails("6002") = "Windows Vista"
OSVersionDetails("3790") = "Windows XP (NT 5.2)"
OSVersionDetails("2710") = "Windows XP"
OSVersionDetails("2700") = "Windows XP"
OSVersionDetails("2600") = "Windows XP"
OSVersionDetails("3000") = "Windows Me"
OSVersionDetails("2195") = "Windows 2000"
OSVersionDetails("2222A") = "Windows 98SE"
OSVersionDetails("1998") = "Windows 98"
OSVersionDetails("1381") = "Windows NT4.0"
OSVersionDetails("950") = "Windows 95"

My old Win 7 laptop returned 6.1.7601.
Quin
Addict
Addict
Posts: 1122
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: My Own OS Version test [Win Only]

Post by Quin »

Very cool, just tested on Win 10 21H2 and it works perfectly :)
Randy Walker
Addict
Addict
Posts: 989
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: My Own OS Version test [Win Only]

Post by Randy Walker »

Axolotl wrote: Wed Apr 02, 2025 1:31 pm
You can check if the app is on a server with this...
What app is it you are checking for? I don't see that in your code.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Randy Walker
Addict
Addict
Posts: 989
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: My Own OS Version test [Win Only]

Post by Randy Walker »

I ran the 2nd block of code and it agrees with HWiNFO64
Very Cool. 8)
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
BarryG
Addict
Addict
Posts: 4122
Joined: Thu Apr 18, 2019 8:17 am

Re: My Own OS Version test [Win Only]

Post by BarryG »

Is all this saying that we can't rely on using the OSVersion() command for some reason?
Quin
Addict
Addict
Posts: 1122
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: My Own OS Version test [Win Only]

Post by Quin »

BarryG wrote: Sat Apr 05, 2025 1:45 am Is all this saying that we can't rely on using the OSVersion() command for some reason?
I think the idea is just to document how this is done in case OSVersion is out-of-date again in the future, like it was for the Mac for a few years until recently.
Axolotl
Enthusiast
Enthusiast
Posts: 798
Joined: Wed Dec 31, 2008 3:36 pm

Re: My Own OS Version test [Win Only]

Post by Axolotl »

Quin wrote: Sat Apr 05, 2025 1:56 am
BarryG wrote: Sat Apr 05, 2025 1:45 am Is all this saying that we can't rely on using the OSVersion() command for some reason?
I think the idea is just to document how this is done in case OSVersion is out-of-date again in the future, like it was for the Mac for a few years until recently.
exactly.

I just followed the information from M$, wikipedia and others and tried to create something useful (applicable).
I think it's very important to note from M$ that you shouldn't infer functionality from the OS version. See Quote on first post.
Randy Walker wrote: Sat Apr 05, 2025 1:06 am
Axolotl wrote: Wed Apr 02, 2025 1:31 pm
You can check if the app is on a server with this...
What app is it you are checking for? I don't see that in your code.
Well, I only tested the API function IsWindowsServer() in the first code block. I don't need this, I was just curious. (As always)
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
Axolotl
Enthusiast
Enthusiast
Posts: 798
Joined: Wed Dec 31, 2008 3:36 pm

Re: My Own OS Version test [Win Only]

Post by Axolotl »

DeanH wrote: Fri Apr 04, 2025 11:14 pm https://en.wikipedia.org/wiki/List_of_M ... _versions

From that I worked out:
OSVersionDetails("9600") = "Windows 8.1"
OSVersionDetails("9200") = "Windows 8"
OSVersionDetails("7601") = "Windows 7"
OSVersionDetails("6002") = "Windows Vista"
OSVersionDetails("3790") = "Windows XP (NT 5.2)"
OSVersionDetails("2710") = "Windows XP"
OSVersionDetails("2700") = "Windows XP"
OSVersionDetails("2600") = "Windows XP"
OSVersionDetails("3000") = "Windows Me"
OSVersionDetails("2195") = "Windows 2000"
OSVersionDetails("2222A") = "Windows 98SE"
OSVersionDetails("1998") = "Windows 98"
OSVersionDetails("1381") = "Windows NT4.0"
OSVersionDetails("950") = "Windows 95"

My old Win 7 laptop returned 6.1.7601.
Thanks DeanH, honestly I was too lazy to add them all because I can't even test them.....
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
breeze4me
Enthusiast
Enthusiast
Posts: 633
Joined: Thu Mar 09, 2006 9:24 am
Location: S. Kor

Re: My Own OS Version test [Win Only]

Post by breeze4me »

BarryG wrote: Sat Apr 05, 2025 1:45 am Is all this saying that we can't rely on using the OSVersion() command for some reason?
In addition to Quin's answer, it can also be used to determine the actual version of Windows that is running.
If the “Compatibility mode” in the “Compatibility” tab of the file properties is set to a different version of Windows than the current one, PB's OSVersion() function or RtlGetVersion function will return the value set there.
However, Axolotl's way or reading from the registry or using the RtlGetNtVersionNumbers function can tell you the actual version of Windows that is running. Regardless of what the compatibility mode setting is.

Compile the code below, change the “Compatibility mode” of the executable, and run it to see the difference.
Tested on Windows 10 Home 22H2.

Code: Select all


#RRF_RT_REG_DWORD = $10
#RRF_RT_REG_SZ = $2
#RRF_ZEROONFAILURE = $20000000

; https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-reggetvaluew
; Windows Vista+
Import "Advapi32.lib"
  RegGetValueW.l(hkey, SubKey.s, Value.s, dwFlags.l, *pdwType, *pvData, *pcbData)
EndImport

Procedure GetOSVersionRegistry(*OSVersion.OSVERSIONINFO)
  Protected hKey
  Protected BufferSize.l
  Protected Buffer.s{16}
  
  If RegOpenKeyEx_(#HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion", 0, #KEY_READ, @hKey) = #ERROR_SUCCESS
    If hKey
      BufferSize = SizeOf(Long)
      If RegGetValueW(hKey, "", "CurrentMajorVersionNumber", #RRF_RT_REG_DWORD | #RRF_ZEROONFAILURE, 0, @*OSVersion\dwMajorVersion, @BufferSize) = #ERROR_SUCCESS
        BufferSize = SizeOf(Long)
        If RegGetValueW(hKey, "", "CurrentMinorVersionNumber", #RRF_RT_REG_DWORD | #RRF_ZEROONFAILURE, 0, @*OSVersion\dwMinorVersion, @BufferSize) = #ERROR_SUCCESS
          
        EndIf
      EndIf
      
      If *OSVersion\dwMajorVersion < 10
        BufferSize = 30
        If RegGetValueW(hKey, "", "CurrentVersion", #RRF_RT_REG_SZ | #RRF_ZEROONFAILURE, 0, @Buffer, @BufferSize) = #ERROR_SUCCESS
          If Buffer
            *OSVersion\dwMajorVersion = Val(StringField(Buffer, 1, "."))
            *OSVersion\dwMinorVersion = Val(StringField(Buffer, 2, "."))
          EndIf
        EndIf
      EndIf
      
      Buffer = ""
      BufferSize = 30
      If RegGetValueW(hKey, "", "CurrentBuildNumber", #RRF_RT_REG_SZ | #RRF_ZEROONFAILURE, 0, @Buffer, @BufferSize) = #ERROR_SUCCESS
        If Buffer
          *OSVersion\dwBuildNumber = Val(Buffer)
        Else
          BufferSize = 30
          If RegGetValueW(hKey, "", "CurrentBuild", #RRF_RT_REG_SZ | #RRF_ZEROONFAILURE, 0, @Buffer, @BufferSize) = #ERROR_SUCCESS
            If Buffer
              *OSVersion\dwBuildNumber = Val(Buffer)
            EndIf
          EndIf
        EndIf
      EndIf
      
      RegCloseKey_(hKey)
    EndIf
  EndIf
EndProcedure

Procedure.s GetOSVersionName() 
  Protected result.s, NP, text.s, stdout.s, strleft.s, lenleft   

  ; INPUT : > ver 
  ; OUTPUT: Microsoft Windows [Version 10.0.22631.5039]
  ;
  NP = RunProgram("cmd.exe", "/C ver", "", #PB_Program_Open|#PB_Program_Read|#PB_Program_Hide) 
  If NP
    strleft = "Microsoft Windows [Version "     ; <-- look for this 
    lenleft = Len(strleft)                      ; <-- number of chars 
    While ProgramRunning(NP)
      If AvailableProgramOutput(NP)
        stdout = ReadProgramString(NP) 
        If Left(stdout, lenleft) = strleft 
          For i = 1 To 3
            result + StringField(Mid(stdout, lenleft+1), i, ".") + "."
          Next
          result = RTrim(result, ".")
        EndIf 
      EndIf
    Wend
    CloseProgram(NP)                            ; Close the connection to the program
  EndIf

  ProcedureReturn result 
EndProcedure 


#STATUS_SUCCESS = 0
Procedure GetOSVersion(*OSVersion.OSVERSIONINFOEX)
  Protected Result, LibNtDll = OpenLibrary(#PB_Any, "Ntdll.dll")
  If LibNtDll
    If *OSVersion
      *OSVersion\dwOSVersionInfoSize = SizeOf(OSVERSIONINFOEX)
      If CallFunction(LibNtDll, "RtlGetVersion", *OSVersion) = #STATUS_SUCCESS
        Result = 1
      EndIf
    EndIf
    CloseLibrary(LibNtDll)
  EndIf
  ProcedureReturn Result
EndProcedure

Procedure GetOSVersion2(*OSVersion.OSVERSIONINFO)
  Protected LibNtDll = OpenLibrary(#PB_Any, "Ntdll.dll")
  If LibNtDll
    *RtlGetNtVersionNumbers = GetFunction(LibNtDll, "RtlGetNtVersionNumbers")
    If *RtlGetNtVersionNumbers
      CallFunctionFast(*RtlGetNtVersionNumbers, @*OSVersion\dwMajorVersion, @*OSVersion\dwMinorVersion, @*OSVersion\dwBuildNumber)
      
      *OSVersion\dwBuildNumber & $FFFF
    EndIf
    
    CloseLibrary(LibNtDll)
  EndIf
EndProcedure


GetOSVersion(ver1.OSVERSIONINFOEX)
GetOSVersionRegistry(ver2.OSVERSIONINFO)
GetOSVersion2(ver3.OSVERSIONINFO)

MessageRequester("Windows ver.", "PB OSVersion: " + OSVersion() + #LF$ +
                                 "RtlGetVersion: " + ver1\dwMajorVersion + "." + ver1\dwMinorVersion + "." + ver1\dwBuildNumber + #LF$ +
                                 "--------------------------------------------" + #LF$ +
                                 "cmd ver: " + GetOSVersionName() + #LF$ +
                                 "Registry: " + ver2\dwMajorVersion + "." + ver2\dwMinorVersion + "." + ver2\dwBuildNumber + #LF$ +
                                 "RtlGetNtVersionNumbers: " + ver3\dwMajorVersion + "." + ver3\dwMinorVersion + "." + ver3\dwBuildNumber)
Randy Walker
Addict
Addict
Posts: 989
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: My Own OS Version test [Win Only]

Post by Randy Walker »

Axolotl wrote: Sat Apr 05, 2025 11:08 am
What app is it you are checking for? I don't see that in your code.
[/quote]
Well, I only tested the API function IsWindowsServer() in the first code block. I don't need this, I was just curious. (As always)
[/quote]
Seems to me you might be interested in the winget command using findstr for further refinement. Example here looking for Notepad:
winget list |findstr /c:Notepad
Execute that line at cmd or powershell prompt. Administrator is not necessary, but works same there too.
Or, if you're trying to capture results in your code then add something like this:

Code: Select all

exe = RunProgram("winget"," List","",#PB_Program_Hide|#PB_Program_Open|#PB_Program_Read|#PB_Program_Error)
If Exe
  While ProgramRunning(Exe)
    If AvailableProgramOutput(Exe)
      Output$=ReadProgramString(Exe)
      error$ = ReadProgramError(Exe)
      If FindString(Output$,"Notepad")
        Debug Trim(Output$)
      EndIf  
    EndIf
  Wend
  CloseProgram(exe)
EndIf
Also do this for more info on winget:
winget /help
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
User avatar
DeanH
Enthusiast
Enthusiast
Posts: 274
Joined: Wed May 07, 2008 4:57 am
Location: Adelaide, South Australia
Contact:

Re: My Own OS Version test [Win Only]

Post by DeanH »

For what its worth, here is my take. I have combined code from above. There are two versions of the WinVer procedure. WinVerS() returns a string and WinVer() returns the same number as PureBasic's OSVersion() function. It should work on quite a few versions of PureBasic. Tested on Windows 11 23H2, Windows 10 22H2 (32 and 64 bit) and Windows Server 2022. Also tested with PureBasic 6.21 beta4, 6.11, 6.01, and 5.31 both 32 and 64 bit.

Thank you everyone in this discussion.

Code: Select all

;Winver

Procedure GetOSVersion(*OSVersion.OSVERSIONINFO)
	Protected LibNtDll = OpenLibrary(#PB_Any, "Ntdll.dll")
	If LibNtDll
		*RtlGetNtVersionNumbers = CallFunction(LibNtDll,"RtlGetNtVersionNumbers", @*OSVersion\dwMajorVersion, @*OSVersion\dwMinorVersion, @*OSVersion\dwBuildNumber)
		*OSVersion\dwBuildNumber & $FFFF
		CloseLibrary(LibNtDll)
	EndIf
EndProcedure

Procedure$ WinVerS()
	Protected result$, build$, server
	*OSVersion.OSVERSIONINFO
	NewMap OSVersionDetails.s()
	NewMap OSServerVersionDetails.s()
	
	OSVersionDetails("26100") = "Windows 11 (24H2)"	;server 2025
	OSVersionDetails("25398") = "Windows Server 2022 (23H2)"
	OSVersionDetails("22631") = "Windows 11 (23H2)"
	OSVersionDetails("22621") = "Windows 11 (22H2)"
	OSVersionDetails("22000") = "Windows 11 (21H2)"
	OSVersionDetails("20348") = "Windows Server 2022"
	OSVersionDetails("19045") = "Windows 10 (22H2)"
	OSVersionDetails("19044") = "Windows 10 (21H2)"
	OSVersionDetails("19043") = "Windows 10 (21H1)"
	OSVersionDetails("19042") = "Windows 10 (20H2)"	;server 20H2
	OSVersionDetails("19041") = "Windows 10 (2004)"	;server 2004
	OSVersionDetails("18363") = "Windows 10 (1909)"	;server 1909
	OSVersionDetails("18362") = "Windows 10 (1903)"	;server 1903
	OSVersionDetails("17763") = "Windows 10 (1809)"	;Server 2019 server 1809
	OSVersionDetails("17134") = "Windows 10 (1803)"	;server 1803
	OSVersionDetails("16299") = "Windows 10 (1709)"	;server 1709
	OSVersionDetails("15063") = "Windows 10 (1703)"
	OSVersionDetails("14393") = "Windows 10 (1607)"	;server 2016
	OSVersionDetails("10586") = "Windows 10 (1511)"
	OSVersionDetails("10240") = "Windows 10 (1507)"
	OSVersionDetails("9600") = "Windows 8.1"	;server 2012 R2
	OSVersionDetails("9200") = "Windows 8"		;also server 2012
	OSVersionDetails("7601") = "Windows 7"		;also server 2008 R2
	OSVersionDetails("6003") = "Windows Server 2008"
	OSVersionDetails("6002") = "Windows Vista"
	OSVersionDetails("3790") = "Windows XP"	;also server 2003
	OSVersionDetails("3000") = "Windows Me"
	OSVersionDetails("2710") = "Windows XP"
	OSVersionDetails("2700") = "Windows XP"
	OSVersionDetails("2600") = "Windows XP"
	OSVersionDetails("2195") = "Windows 2000"
	OSVersionDetails("2222A") = "Windows 98SE"
	OSVersionDetails("1998") = "Windows 98"
	OSVersionDetails("1381") = "Windows NT4.0"
	OSVersionDetails("950") = "Windows 95"
	
	OSServerVersionDetails("26100") = "Windows Server 2025"
	OSServerVersionDetails("25398") = "Windows Server 2022 (23H2)"
	OSServerVersionDetails("20348") = "Windows Server 2022 (21H2)"
	OSServerVersionDetails("19042") = "Windows Server 2019 (20H2)"
	OSServerVersionDetails("19041") = "Windows Server 2019 (2004)"
	OSServerVersionDetails("18363") = "Windows Server 2019 (1909)"
	OSServerVersionDetails("18362") = "Windows Server 2019 (1903)"
	OSServerVersionDetails("17763") = "Windows Server 2019 (1809)"
	OSServerVersionDetails("17134") = "Windows Server 2016 (1803)"
	OSServerVersionDetails("16299") = "Windows Server 2016 (1709)"
	OSServerVersionDetails("14393") = "Windows Server 2016 (1607)"
	OSServerVersionDetails("9600") = "Windows Server 2012 R2"
	OSServerVersionDetails("9200") = "Windows Server 2012"
	OSServerVersionDetails("7601") = "Windows Server 2008 R2"
	OSServerVersionDetails("6003") = "Windows Server 2008"
	OSServerVersionDetails("3790") = "Windows Server 2003"
	OSServerVersionDetails("2195") = "Windows Server 2000"
	
	GetOSVersion(ver.OSVERSIONINFO)
	build$=Str(ver\dwBuildNumber)
	result$ = OSVersionDetails(build$)

	server=#False
	If OpenLibrary(0,"Kernel32.dll")
		server=CallFunction(0,"IsWindowsServer")
		CloseLibrary(0)
	EndIf
	If server
		result$ = OSServerVersionDetails(build$)
		If result$ = ""
			result$="Windows Server NT"
		EndIf
	EndIf
	
	ProcedureReturn result$
EndProcedure 

Procedure.i WinVer()
	Protected result, build$, server
	*OSVersion.OSVERSIONINFO
	NewMap OSVersionDetails.i()
	NewMap OSServerVersionDetails.i()
	
	OSVersionDetails("26100") = 120		;Windows 11 (24H2)
	OSVersionDetails("25398") = 120		;Windows Server 2202 (23H2)
	OSVersionDetails("22631") = 120		;Windows 11 (23H2)
	OSVersionDetails("22621") = 120		;Windows 11 (22H2)
	OSVersionDetails("22000") = 120		;Windows 11 (21H2)
	OSVersionDetails("20348") = 116		;Windows Server 2022
	OSVersionDetails("19045") = 110		;Windows 10 (22H2)
	OSVersionDetails("19044") = 110		;Windows 10 (21H2)
	OSVersionDetails("19043") = 110		;Windows 10 (21H1)
	OSVersionDetails("19042") = 110		;Windows 10 (20H2)
	OSVersionDetails("19041") = 110		;Windows 10 (2004)
	OSVersionDetails("18363") = 110		;Windows 10 (1909)
	OSVersionDetails("18362") = 110		;Windows 10 (1903)
	OSVersionDetails("17763") = 110		;Windows 10 (1809)
	OSVersionDetails("17134") = 110			;Windows 10 (1803)
	OSVersionDetails("16299") = 110		;Windows 10 (1709)
	OSVersionDetails("15063") = 110		;Windows 10 (1703)
	OSVersionDetails("14393") = 110		;Windows 10 (1607)
	OSVersionDetails("10586") = 110		;Windows 10 (1511)
	OSVersionDetails("10240") = 110		;Windows 10 (1507)
	OSVersionDetails("9600") = 100		;Windows 8.1
	OSVersionDetails("9200") = 90		;Windows 8
	OSVersionDetails("7601") = 80		;Windows 7
	OSVersionDetails("6003") = 75		;Windows Server 2008
	OSVersionDetails("6002") = 70		;Windows Vista
	OSVersionDetails("3790") = 60		;Windows XP
	OSVersionDetails("3000") = 40		;Windows Me
	OSVersionDetails("2710") = 60		;Windows XP
	OSVersionDetails("2700") = 60		;Windows XP
	OSVersionDetails("2600") = 60		;Windows XP
	OSVersionDetails("2195") = 50		;Windows 2000
	OSVersionDetails("2222A") = 30		;Windows 98SE
	OSVersionDetails("1998") = 30		;Windows 98
	OSVersionDetails("1381") = 20		;Windows NT4.0
	OSVersionDetails("950") = 10			;Windows 95
	
	OSServerVersionDetails("26100") = 122	;Windows Server 2025
	OSServerVersionDetails("25398") = 116	;Windows Server 2022 (23H2)
	OSServerVersionDetails("20348") = 116	;Windows Server 2022 (21H2)
	OSServerVersionDetails("19042") = 114	;Windows Server 2019 (20H2)
	OSServerVersionDetails("19041") = 114	;Windows Server 2019 (2004)
	OSServerVersionDetails("18363") = 114	;Windows Server 2019 (1909)
	OSServerVersionDetails("18362") = 114	;Windows Server 2019 (1903)
	OSServerVersionDetails("17763") = 114	;Windows Server 2019 (1809)
	OSServerVersionDetails("17134") = 112	;Windows Server 2016 (1803)
	OSServerVersionDetails("16299") = 112	;Windows Server 2016 (1709)
	OSServerVersionDetails("14393") = 112	;Windows Server 2016 (1607)
	OSServerVersionDetails("9600") = 105	;Windows Server 2012 R2
	OSServerVersionDetails("9200") = 95		;Windows Server 2012
	OSServerVersionDetails("7601") = 85		;Windows Server 2008 R2
	OSServerVersionDetails("6003") = 75		;Windows Server 2008
	OSServerVersionDetails("3790") = 65		;Windows Server 2003
	OSServerVersionDetails("2195") = 55		;Windows Server 2000
	
	GetOSVersion(ver.OSVERSIONINFO)
	build$=Str(ver\dwBuildNumber)
	result = OSVersionDetails(build$)
	
	server=#False
	If OpenLibrary(0,"Kernel32.dll")
		server=CallFunction(0,"IsWindowsServer")
		CloseLibrary(0)
	EndIf
	If server
		result = OSServerVersionDetails(build$)
	EndIf
	
	ProcedureReturn result
EndProcedure 

MessageRequester("Win ver",Str(WinVer())+#CRLF$+#CRLF$+WinVerS())

Quin
Addict
Addict
Posts: 1122
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: My Own OS Version test [Win Only]

Post by Quin »

Very nice! Tested on Windows 10 21H2 IoT LTSC, and can confirm it works like expected with PB 6.12, 6.20 and 6.21 B4.
Post Reply