Click here to Skip to main content
Click here to Skip to main content

Windows version requirements macros

By , 1 Jun 2005
 

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

About the Author

Dalibor Drzik
Web Developer
Slovakia Slovakia
Member
Wink | ;-)

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMacro does not workmemberbantisk8 Aug '06 - 21:22 
These Micros Will work on VC++ 1.52 IDE. It shows correct operating system upt0 windows me. NT based system like 2000 and Xp are not reported correctly. Getversion() return value seems to be the problem
 
bantisk
AnswerRe: Macro does not workmemberDalibor Drzik22 Aug '06 - 1:48 
GeneralRe: Macro does not workmemberbantisk23 Aug '06 - 0:57 
QuestionWhy are you using macros?memberDon Clugston1 Jun '05 - 20:42 
AnswerRe: Why are you using macros?memberDalibor Drzik2 Jun '05 - 0:15 
GeneralRe: Why are you using macros?sussAnonymous2 Jun '05 - 15:18 
GeneralRe: Why are you using macros?memberDalibor Drzik3 Jun '05 - 12:08 
GeneralRe: Why are you using macros?memberF5Tiger14 Jun '05 - 21:18 
GeneralRe: Why are you using macros?memberDalibor Drzik18 Jun '05 - 0:01 
GeneralRe: Why are you using macros?memberDon Clugston5 Jun '05 - 22:04 
GeneralRe: Why are you using macros?memberDalibor Drzik6 Jun '05 - 3:15 
GeneralRe: Why are you using macros?memberPablo Aliskevicius7 Jun '05 - 20:07 
GeneralRe: Why are you using macros?memberDalibor Drzik9 Jun '05 - 2:30 

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 2 Jun 2005
Article Copyright 2005 by Dalibor Drzik
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid