Click here to Skip to main content
Click here to Skip to main content
Go to top

Windows version requirements macros

, 1 Jun 2005
Rate this:
Please Sign up or sign in to vote.
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

Share

About the Author

Dalibor Drzik
Web Developer
Slovakia Slovakia
Wink | ;-)

Comments and Discussions

 
GeneralMacro does not work Pinmemberbantisk8-Aug-06 21:22 
AnswerRe: Macro does not work PinmemberDalibor Drzik22-Aug-06 1:48 
GeneralRe: Macro does not work Pinmemberbantisk23-Aug-06 0:57 
QuestionWhy are you using macros? PinmemberDon Clugston1-Jun-05 20:42 
AnswerRe: Why are you using macros? PinmemberDalibor Drzik2-Jun-05 0:15 
GeneralRe: Why are you using macros? PinsussAnonymous2-Jun-05 15:18 
GeneralRe: Why are you using macros? PinmemberDalibor Drzik3-Jun-05 12:08 
GeneralRe: Why are you using macros? PinmemberF5Tiger14-Jun-05 21:18 
GeneralRe: Why are you using macros? PinmemberDalibor Drzik18-Jun-05 0:01 
GeneralRe: Why are you using macros? PinmemberDon Clugston5-Jun-05 22:04 
GeneralRe: Why are you using macros? PinmemberDalibor Drzik6-Jun-05 3:15 
GeneralRe: Why are you using macros? PinmemberPablo Aliskevicius7-Jun-05 20:07 
GeneralRe: Why are you using macros? PinmemberDalibor Drzik9-Jun-05 2:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140926.1 | Last Updated 2 Jun 2005
Article Copyright 2005 by Dalibor Drzik
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid