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
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