Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Windows version requirements macros

0.00/5 (No votes)
1 Jun 2005 1  
Operating system version requirements to the corresponding values for the currently running version of the system.

Introduction

The GetVersion function returns the current version number of the operating system. If the function succeeds, the return value is a DWORD value that contains the major and minor version numbers of the operating system in the low order word, and information about the operating system platform in the high order word.

For all platforms, the low order word contains the version number of the operating system. The low-order byte of this word specifies the major version number, in hexadecimal notation. The high-order byte specifies the minor version (revision) number, in hexadecimal notation.

In the table, you can find the examples for several Windows platforms:

Windows version numbers table

Often programmers need to get the currently running version of the system. The code in this article will show you how to identify the Windows platforms.

Macros definition

Windows version macros compare operating system version requirements to the corresponding values for the currently running version of the system. This enables you to easily determine the presence of a required set of operating system version conditions.

//Windows version macros


#define WinVerMajor()        LOBYTE(LOWORD(GetVersion()))
#define WinVerMinor()        HIBYTE(LOWORD(GetVersion()))

#define IsWinVerNTs()        (GetVersion() < 0x80000000)
#define IsWinVerNT351Plus()  (IsWinVerNTs() && WinVerMajor() >= 3)
#define IsWinVerNT4Plus()    (IsWinVerNTs() && WinVerMajor() > 3)
#define IsWinVer98Plus()     (LOWORD(GetVersion()) != 4)
#define IsWinVerMEPlus()     (WinVerMajor() >= 5 || WinVerMinor() > 10)
#define IsWinVer2000Plus()   (WinVerMajor() >= 5)
#define IsWinVerXPPlus()     (WinVerMajor() >= 5 && LOWORD(GetVersion()) != 5)

If the currently running operating system satisfies the specified requirements, the return value is a nonzero value. If the current system does not satisfy the requirements, the return value is zero.

Windows version numbers table

Using the macros

These examples will show you how easilyy you can use the macros in your applications:

// Example 1:

if (IsWinVerMEPlus())
{
    printf("If you can see this message you" 
           " are running Windows ME or higher! \n");
}
else
{
    printf("If you can see this message you are running Windows 95 or 98! \n");
}

// Example 2:

if (IsWinVerXPPlus())
{
    // Jun-01-2005

    printf("If you can see this message you are running Windows XP or 2003! \n");
}

// Example 3:

if (IsWinVer2000Plus())
{
    printf("Your operating system supports the opacity" 
           " and transparency color key of a layered window! \n");
}

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here