System & Version

General FreeBASIC programming questions.
Post Reply
unknown
Posts: 472
Joined: Aug 06, 2005 0:53
Contact:

System & Version

Post by unknown »

Is there a way to retrieve which system is running, (XP, Linux, DOS) and it's version, (specifically windows, 98/XP/Vista)?
Vendan
Posts: 48
Joined: Sep 18, 2006 0:25

Post by Vendan »

It's a bit jury rigged, but here

Code: Select all

#ifdef __FB_WIN32__
#include "windows.bi"
#endif
#ifdef __FB_LINUX_
Print "I'm on Linux!"
#endif
#ifdef __FB_DOS__
print "Im on Dos!"
#endif
#ifdef __FB_WIN32__
dim WindowsVersion as OSVERSIONINFO
WindowsVersion.dwOSVersionInfoSize = len(OSVERSIONINFO)
GetVersionEx(@WindowsVersion)
select case WindowsVersion.dwMajorVersion
	case 4
		select case WindowsVersion.dwMinorVersion
			case 0
				if WindowsVersion.dwPlatformId = 2 then
					print "I'm on Windows NT"
				else
					print "I'm on Windows 95
				end if
			case 10
				print "I'm on Windows 98"
			case 90
				print "I'm on Windows ME"
		end select
	case 5
		select case WindowsVersion.dwMinorVersion
			case 0
				print "I'm on Windows 2000"
			case 1
				print "I'm on Windows XP"
			case 2
				print "I'm on Windows 2003, Windows 2003 R2, or Windows XP x64"
		end select
	case 6
		select case WindowsVersion.dwMinorVersion
			case 0
				print "I'm on Windows Vista or Windows Server 'Longhorn'"
		end select
end select
#endif
unknown
Posts: 472
Joined: Aug 06, 2005 0:53
Contact:

Post by unknown »

Thank you, Sir. That example was exactly what I needed.
Post Reply