[bmx] Windows version detection by BlitzSupport [ 1+ years ago ]

Started by BlitzBot, June 29, 2017, 00:28:40

Previous topic - Next topic

BlitzBot

Title : Windows version detection
Author : BlitzSupport
Posted : 1+ years ago

Description : Prints out the version of Windows upon which the program is running...

Code :
Code: blitzmax
Type OSVERSIONINFOEX
	Field dwOSVersionInfoSize:Int
	Field dwMajorVersion:Int
	Field dwMinorVersion:Int
	Field dwBuildNumber:Int
	Field dwPlatformId:Int
	Field szCSDVersion:Int[32] ' 128 bytes
	Field wServicePackMajor:Short
	Field wServicePackMinor:Short
	Field wSuiteMask:Short
	Field wProductType:Byte
	Field wReserved:Byte
End Type

Const SIZEOF_OSVERSIONINFOEX:Int = 156

Const VER_NT_WORKSTATION:Int = 1
Const VER_NT_DOMAIN_CONTROLLER:Int = 2
Const VER_NT_SERVER:Int = 3

Extern "win32"
	Function GetVersionExA:Int (version:Byte Ptr)
	Function GetSystemMetrics:Int (index:Int)
	Function GetSystemInfo:Int (info:Byte Ptr)
End Extern

Local version:OSVERSIONINFOEX = New OSVERSIONINFOEX
version.dwOSVersionInfoSize = SIZEOF_OSVERSIONINFOEX

If GetVersionExA (version)

	' Using table at http://msdn.microsoft.com/en-us/library/windows/desktop/ms724833(v=vs.85).aspx

	Select version.dwMajorVersion
	
		' NB. The REM'd comments refer to alternative server versions. See above URL for
		' PARTIAL method of sub-detection (doesn't cover all variants, eg. 32/64)...
		
		Case 5
			
			Select version.dwMinorVersion
				Case 0
					Print "Windows 2000"
				Case 1
					Print "Windows XP"
				Case 2
					Print "Windows XP 64-bit"	' and Server 2003/Server 2003 R2/Home Server"
			End Select
			
		Case 6
		
			Select version.dwMinorVersion
				Case 0
					Print "Windows Vista"		' and Server 2008
				Case 1
					Print "Windows 7"			' and Windows Server 2008 R2
				Case 2
					Print "Windows 8"			' and Windows Server 2012
			End Select
			
	End Select
	
EndIf


Comments :


BlitzSupport(Posted 1+ years ago)

 Note: For Windows NT systems from Windows 2000+ only!