Sam Rowlands has posted on ohanaware.com a way to get the version and build number for macOS, but I would like to have that as well for Windows.
Christian, I am sure you have something, but I was not able to find that on your site… Can you help ?
Sam Rowlands has posted on ohanaware.com a way to get the version and build number for macOS, but I would like to have that as well for Windows.
Christian, I am sure you have something, but I was not able to find that on your site… Can you help ?
Hi Michel, try this SystemInformationMBS and either OSVerstionString
or WinBuildNumber
.
I hope that’s what you’re looking for. Good luck!
You can also check the Registry: Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentBuild or CurrentBuildNumber
WMI and PowerShell can also access this information.
Here is a useful summary: https://www.tenforums.com/tutorials/23975-find-windows-10-build-number.html
and PowerShell: https://stackoverflow.com/questions/7330187/how-to-find-the-windows-version-from-the-powershell-command-line
You can also get it from kernel32.dll using GetFileVersionInfo and VerQueryValue
I wrote this a while ago for someone https://www.dropbox.com/s/6v42szgbq0wzc3r/GetFileVersionInfo.xojo_binary_project?dl=0 on the forum.
You can also use this free class from me. It uses the GetVersionExA
function from Kernel32.dll
It gets major, minor and build numbers. You can get the full string or the structure to pick the desired value.
Maybe: SystemInformationMBS.OSVersionString ?
Just for completion (macOS side). If you need to get the Build version on macOS (you can use System.Version to get the version data on all the supported platforms since 2019r3 for that), then you can parse the string returned by the following code:
Declare Function NSClassFromString Lib "Foundation" (className As CFStringRef) As ptr
Var NSClassName As ptr = NSClassFromString("NSProcessInfo")
Declare Function ProcessInfo Lib "Foundation" selector "processInfo" (cobj As ptr) As ptr
Var NSProcInfo As ptr = NSProcessInfo( NSClassName )
Declare Function NSversionString Lib "Foundation" selector "operatingSystemVersionString" ( procInfo As ptr) As CFStringRef
Return NSversionString( NSProcInfo )
Works on all Platforms and gives a String like this: Windows 10 (Build 18362) or Windows Server 2012 R2 (Build 9600)
And just to add one more way:
Get the Shell Output of this command: ver
It looks like this:
Microsoft Windows [Version 10.0.18362.535]
Whao! I am elated to see so many great answers.
Thank you so much to all.
I have more than enough to implement, now.
AXOSVersion Class (free): enhanced to support both macOS / Windows, giving access to every value (major, minor and build version) and the combined String.
Hope it helps!
Javier
Actually, I have already implemented the MBS solution in both Mac and Windows.
In Windows, I was chasing a nasty intermittent bug that manifested sometimes at lauch, and I could not figure what was going on.
I then decided to present the user with a window, just like macOS does, showing the stack, and asking permission to send in order to help. I then sent by HTTPSocket to a web service. With the complete information about system version.
Lo and Behold, I received almost immediately a report, as soon as the new version was released.
I was testing the presence of a keyboard by taping into the Registry. I assumed all version of Windows had that key. How was I wrong: trying to access a key that is not there triggered a nil object exception. The one I had been chasing for now six months or so.
Version 3.82 will be on it’s way this afternoon, without the random bug