Win32 Lean And Mean

In this article

The header files for the Windows API enable you to develop 32- and 64-little bit applications. They incorporate declarations for both Unicode and ANSI versions of the API. For more information, see Unicode in the Windows API. They use data varieties that permit you to build both 32- and 64-little versions of your application from a single resource code base. For even more information, see Getting Ready for 64-little bit Windows. Additional attributes incorporate Header Annotations and also STRICT Type Checking.

You watching: Win32 lean and mean

Visual C++ and also the Windows Header Files Visual C++ has duplicates of the Windows header documents that were present at the moment Visual C++ was released. As such, if you install updated header files from an SDK, you might finish up through multiple versions of the Windows header records on your computer system. If you execute not encertain that you are utilizing the latest version of the SDK header files, you will receive the adhering to error code as soon as compiling code that uses functions that were presented after Visual C++ was released: error C2065: undeclared identifier.

Macros for Conditional Declarations

Certain features that depend on a certain version of Windows are asserted using conditional code. This permits you to use the compiler to detect whether your application supplies attributes that are not supported on its taracquire version(s) of Windows. To compile an application that provides these functions, you need to define the proper macros. Otherwise, you will certainly obtain the C2065 error message.

The Windows header records use macros to suggest which versions of Windows assistance many programming facets. Therefore, you need to define these macros to usage new use presented in each major operating mechanism release. (Individual header documents might use various macros; therefore, if compilation problems occur, check the header file that includes the meaning for conditional definitions.) For even more indevelopment, check out SdkDdkVer.h.

The adhering to table describes the desired macros supplied in the Windows header files. If you specify NTDDI_VERSION, you must additionally define _WIN32_WINNT.

Minimum device requiredValue for NTDDI_VERSION
Windows 10 1903 "19H1"NTDDI_WIN10_19H1 (0x0A000007)
Windows 10 1809 "Redrock 5"NTDDI_WIN10_RS5 (0x0A000006)
Windows 10 1803 "Redrock 4"NTDDI_WIN10_RS4 (0x0A000005)
Windows 10 1709 "Redrock 3"NTDDI_WIN10_RS3 (0x0A000004)
Windows 10 1703 "Redrock 2"NTDDI_WIN10_RS2 (0x0A000003)
Windows 10 1607 "Redrock 1"NTDDI_WIN10_RS1 (0x0A000002)
Windows 10 1511 "Thresorganize 2"NTDDI_WIN10_TH2 (0x0A000001)
Windows 10 1507 "Threshold"NTDDI_WIN10 (0x0A000000)
Windows 8.1NTDDI_WINBLUE (0x06030000)
Windows 8NTDDI_WIN8 (0x06020000)
Windows 7NTDDI_WIN7 (0x06010000)
Windows Server 2008NTDDI_WS08 (0x06000100)
Windows Vista with Service Pack 1 (SP1)NTDDI_VISTASP1 (0x06000100)
Windows VistaNTDDI_VISTA (0x06000000)
Windows Server 2003 through Service Pack 2 (SP2)NTDDI_WS03SP2 (0x05020200)
Windows Server 2003 through Service Pack 1 (SP1)NTDDI_WS03SP1 (0x05020100)
Windows Server 2003NTDDI_WS03 (0x05020000)
Windows XP with Service Pack 3 (SP3)NTDDI_WINXPSP3 (0x05010300)
Windows XP with Service Pack 2 (SP2)NTDDI_WINXPSP2 (0x05010200)
Windows XP through Service Pack 1 (SP1)NTDDI_WINXPSP1 (0x05010100)
Windows XPNTDDI_WINXP (0x05010000)


The following tables describe other macros supplied in the Windows header papers.

Minimum system requiredMinimum worth for _WIN32_WINNT and also WINVER
Windows 10_WIN32_WINNT_WIN10 (0x0A00)
Windows 8.1_WIN32_WINNT_WINBLUE (0x0603)
Windows 8_WIN32_WINNT_WIN8 (0x0602)
Windows 7_WIN32_WINNT_WIN7 (0x0601)
Windows Server 2008_WIN32_WINNT_WS08 (0x0600)
Windows Vista_WIN32_WINNT_VISTA (0x0600)
Windows Server 2003 with SP1, Windows XP through SP2_WIN32_WINNT_WS03 (0x0502)
Windows Server 2003, Windows XP_WIN32_WINNT_WINXP (0x0501)


Minimum variation requiredMinimum value of _WIN32_IE
Net Explorer 11.0_WIN32_IE_IE110 (0x0A00)
Web Explorer 10.0_WIN32_IE_IE100 (0x0A00)
Web Explorer 9.0_WIN32_IE_IE90 (0x0900)
Net Explorer 8.0_WIN32_IE_IE80 (0x0800)
Web Explorer 7.0_WIN32_IE_IE70 (0x0700)
Net Explorer 6.0 SP2_WIN32_IE_IE60SP2 (0x0603)
Web Explorer 6.0 SP1_WIN32_IE_IE60SP1 (0x0601)
Internet Explorer 6.0_WIN32_IE_IE60 (0x0600)
Net Explorer 5.5_WIN32_IE_IE55 (0x0550)
Net Explorer 5.01_WIN32_IE_IE501 (0x0501)
Net Explorer 5.0, 5.0a, 5.0b_WIN32_IE_IE50 (0x0500)


Setting WINVER or _WIN32_WINNT

You can define these symbols by making use of the #specify statement in each resource file, or by specifying the /D compiler alternative sustained by Visual C++.

See more: What Does Meow Mean In Text Meaning, He Texted Me Meow

For example, to set WINVER in your resource file, use the adhering to statement:

#specify WINVER 0x0502

To set _WIN32_WINNT in your source file, usage the following statement:

#specify _WIN32_WINNT 0x0502

To collection _WIN32_WINNT utilizing the /D compiler option, usage the complying with command:

cl -c /D_WIN32_WINNT=0x0502 source.cpp

For indevelopment on utilizing the /D compiler choice, see /D (preprocessor definitions).

Keep in mind that some attributes presented in the latest variation of Windows may be included to a service pack for a previous version of Windows. Therefore, to targain a company load, you might should define _WIN32_WINNT with the worth for the following significant operating system release. For example, the GetDllDirectory feature was presented in Windows Server 2003 and also is conditionally characterized if _WIN32_WINNT is 0x0502 or greater. This attribute was additionally included to Windows XP via SP1. Therefore, if you were to specify _WIN32_WINNT as 0x0501 to target Windows XP, you would certainly miss attributes that are defined in Windows XP via SP1.

Controlling Structure Packing

Projects should be compibrought about usage the default structure packing, which is presently 8 bytes because the largest integral type is 8 bytes. Doing so ensures that all framework forms within the header papers are compiled right into the application through the very same alignment the Windows API expects. It likewise ensures that structures via 8-byte worths are appropriately aligned and also will not cause alignment faults on processors that enforce information alignment.

For more indevelopment, view /Zp (struct member alignment) or pack.

Faster Builds with Smaller Header Files

You can alleviate the dimension of the Windows header papers by excluding some of the less prevalent API declarations as follows:

Define WIN32_LEAN_AND_MEAN to exclude APIs such as Cryptography, DDE, RCOMPUTER, Covering, and Windows Sockets.


Define one or more of the NOapi icons to exclude the API. For instance, NOCOMM excludes the serial communication API. For a list of support NOapi symbols, view Windows.h.