WinVer Function

Requires: gfawinx.lg32

Purpose

Retrieves version information about the currently running operating system.

Syntax

ret = WinVer([IsWindows])

ret: integer or boolean value

Description

When WinVer does not specify a value in its argument, WinVer returns a Long with the OS version in hexadecimal format. The return value can be displayed using the Hex() function. The following values are possible.

0x0400 // Windows NT 4.0
0x0500 // Windows 2000
0x0501 // Windows XP
0x0502 // Windows Server 2003
0x0600 // Windows Vista
0x0600 // Windows Server 2008
0x0601 // Windows 7
0x0602 // Windows 8
0x0603 // Windows 8.1
0x0A00 // Windows 10

However, Microsoft wants us to abandon the old way of obtaining the OS version and wants us to use the newer version-helpers from the VersionHelpers.h SDK file. WinVer implements the version helper functions and wraps them into a single function. To identify the current OS use one of the following self-explanatory constants for the parameter of WinVer:

IsWindowsXPOrGreater
IsWindowsXPSP1OrGreater
IsWindowsXPSP2OrGreater
IsWindowsXPSP3OrGreater
IsWindowsVistaOrGreater
IsWindowsVistaSP1OrGreater
IsWindowsVistaSP2OrGreater
IsWindows7OrGreater
IsWindows7SP1OrGreater
IsWindows8OrGreater
IsWindows8Point1OrGreater
IsWindowsThresholdOrGreater
IsWindows10OrGreater
IsWindowsServer

With the above constants, WinVer returns 0 (False) if the application isn’t running on the requested OS (or greate if applicabler) and –1 (True) if it is.

Example

$Library "gfawinx"

Debug.Show

Debug Hex(WinVer())

If WinVer(IsWindows10OrGreater) Then Debug.Print "Running on Windows 10"

Remarks

WinVer returns false (0) when called by applications that do not have a compatibility manifest for Windows 8.1 or Windows 10 even if the application is running on one of these OSes. The GFA-BASIC 32 version 2.57 includes a compatibility manifest so that functionality of Windows 8.1 and Windows 10 are ‘unlocked’ and WinVer will return True.

For more information see here

See Also

WinVersion.

{Created by Sjouke Hamstra; Last updated: 13/08/2019 by James Gaite}