Windows Target Version Macros

The Win32 SDK does not come in different versions for different platforms.  For example, if you choose to develop for Windows 98, you should work with the same SDK as you would when developing for Windows XP.  The solution Microsoft offers to enforce a minimum system requirement for a particular application works through a set of preprocessor macros used widely in the Windows header files.  These macros are WINVER, _WIN32_WINDOWS, _WIN32_WINNT, and _WIN32_IE.  You should define these macros to a hexadecimal number that varies for each platform.  Here’s a table that indicates which macros need to be defined for developing for a particular platform, and what number should they be defined to.

Windows 95 and NT 4.00x0400n/an/an/a
Windows 98 and NT 4.00x04000x0410n/an/a
Windows NT 4.00x0400n/a0x0400n/a
Windows 98n/a0x0410n/an/a
Windows Men/a0x0490n/an/a
Windows 20000x0500n/a0x0500n/a
Windows XP and Windows .NET Server0x0501n/a0x0501n/a
Internet Explorer 3.0, 3.01, 3.02n/an/an/a0x0300
Internet Explorer 4.0n/an/an/a0x0400
Internet Explorer 4.01n/an/an/a0x0401
Internet Explorer 5.0, 5.0a, 5.0bn/an/an/a0x0500
Internet Explorer 5.01, 5.5n/an/an/a0x0501
Internet Explorer 6.0n/an/an/a0x0560

In order to use the above macros, you should define them before including any other header files.  For example, if you want to develop an application targeting Windows 98, Me, NT 4.0, 2000, XP, with a minimum of Internet Explorer 5.0 installed, you should include Windows headers like this:

#define WINVER         0x0400
#define _WIN32_WINDOWS 0x0410
#define _WIN32_IE 0x0500

#include <windows.h>
// include other necessary headers as well...

You should find the minimum system requirement, and define the macros dependently.  In the above example, the minimum system requirement is Windows 98 and NT 4.0 with Internet Explorer 5.0 installed.  In other words, any application developed with regard to those requirements is compatible with higher system versions.

Note that this is only a compile-time check.  You should perform run-time checks as well.  By being strict in defining the above macros as necessary, you ensure that you won’t use any features that are not present in the target platform.

This article originally appeared on It’s been republished here, and may contain modifications from the original article.

Posted in Visual C++