Skip to content

Commit fec0c35

Browse files
authored
Merge pull request MicrosoftDocs#2640 from corob-msft/cr-1862-target-win-10
Update using Windows 10 SDK article per 1862
2 parents 9a898bd + 3cb51ad commit fec0c35

2 files changed

Lines changed: 67 additions & 23 deletions

File tree

docs/porting/modifying-winver-and-win32-winnt.md

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
---
22
title: "Update WINVER and _WIN32_WINNT"
3-
ms.date: "09/04/2017"
3+
description: "When and how to update WINVER and _WIN32_WINNT macros in upgraded Visual Studio C++ projects."
4+
ms.date: "01/22/2020"
45
helpviewer_keywords: ["WINVER in an upgraded Visual Studio C++ project", "_WIN32_WINNT in an upgraded Visual Studio C++ project"]
56
ms.assetid: 6a1f1d66-ae0e-48a7-81c3-524d8e8f3447
67
---
78
# Update WINVER and _WIN32_WINNT
89

9-
Visual C++ no longer supports targeting Windows 95, Windows 98, Windows ME, Windows NT or Windows 2000. If your **WINVER** or **_WIN32_WINNT** macros are assigned to one of these versions of Windows, you must modify the macros. When you upgrade a project that was created by using an earlier version of Visual C++, you may see compilation errors related to the **WINVER** or **_WIN32_WINNT** macros if they are assigned to a version of Windows that is no longer supported.
10+
When you use the Windows SDK, you can specify which versions of Windows your code can run on. The preprocessor macros **WINVER** and **_WIN32_WINNT** specify the minimum operating system version your code supports. Visual Studio and the Microsoft C++ compiler support targeting Windows 7 SP1 and later. Older toolsets include support for Windows XP SP4, Windows Server 2003 SP4, Vista, and Windows Server 2008. Windows 95, Windows 98, Windows ME, Windows NT, and Windows 2000 are unsupported.
11+
12+
When you upgrade an older project, you may need to update your **WINVER** or **_WIN32_WINNT** macros. If they're assigned values for an unsupported version of Windows, you may see compilation errors related to these macros.
1013

1114
## Remarks
1215

13-
To modify the macros, in a header file (for example, targetver.h which is included when you create a project that targets Windows), add the following lines.
16+
To modify the macros, in a header file (for example, in *targetver.h*, which is included by some project templates that target Windows), add the following lines.
1417

1518
```C
1619
#define WINVER 0x0A00
1720
#define _WIN32_WINNT 0x0A00
1821
```
1922
20-
This targets the Windows 10 operating system. These values are listed in the Windows header file SDKDDKVer.h, which also defines macros for each Windows version. You should add the #define statement before including SDKDDKVer.h. Here are the lines from the Windows 10 version of SDKDDKVer.h that encode the values for each version of Windows:
23+
The macros in the example are set to target every version of the Windows 10 operating system. The possible values are listed in the Windows header file *sdkddkver.h*, which defines macros for each major Windows version. To build your application to support a previous Windows platform, include *WinSDKVer.h*. Then, set the **WINVER** and **_WIN32_WINNT** macros to the oldest supported platform before including *sdkddkver.h*. Here are the lines from the Windows 10 SDK version of *sdkddkver.h* that encode the values for each major version of Windows:
2124
2225
```C
2326
//
@@ -38,7 +41,45 @@ This targets the Windows 10 operating system. These values are listed in the Win
3841
#define _WIN32_WINNT_WIN10 0x0A00 // Windows 10
3942
```
4043

41-
If you don't see all of these versions of Windows listed in a copy of SDKDDKVer.h that you're looking at, you probably are using an older version of the Windows SDK. By default, Win32 projects in Visual Studio 2017 use the Windows 10 SDK.
44+
For a more fine-grained approach to versioning, you can use the NTDDI version constants in *sdkddkver.h*. Here are some of the macros defined by *sdkddkver.h* in Windows 10 SDK version 10.0.18362.0:
45+
46+
```C
47+
//
48+
// NTDDI version constants
49+
//
50+
#define NTDDI_WIN7 0x06010000
51+
#define NTDDI_WIN8 0x06020000
52+
#define NTDDI_WINBLUE 0x06030000
53+
#define NTDDI_WINTHRESHOLD 0x0A000000 /* ABRACADABRA_THRESHOLD */
54+
#define NTDDI_WIN10 0x0A000000 /* ABRACADABRA_THRESHOLD */
55+
#define NTDDI_WIN10_TH2 0x0A000001 /* ABRACADABRA_WIN10_TH2 */
56+
#define NTDDI_WIN10_RS1 0x0A000002 /* ABRACADABRA_WIN10_RS1 */
57+
#define NTDDI_WIN10_RS2 0x0A000003 /* ABRACADABRA_WIN10_RS2 */
58+
#define NTDDI_WIN10_RS3 0x0A000004 /* ABRACADABRA_WIN10_RS3 */
59+
#define NTDDI_WIN10_RS4 0x0A000005 /* ABRACADABRA_WIN10_RS4 */
60+
#define NTDDI_WIN10_RS5 0x0A000006 /* ABRACADABRA_WIN10_RS5 */
61+
#define NTDDI_WIN10_19H1 0x0A000007 /* ABRACADABRA_WIN10_19H1*/
62+
63+
#define WDK_NTDDI_VERSION NTDDI_WIN10_19H1 /* ABRACADABRA_WIN10_19H1 */
64+
65+
//
66+
// masks for version macros
67+
//
68+
#define OSVERSION_MASK 0xFFFF0000
69+
#define SPVERSION_MASK 0x0000FF00
70+
#define SUBVERSION_MASK 0x000000FF
71+
72+
//
73+
// macros to extract various version fields from the NTDDI version
74+
//
75+
#define OSVER(Version) ((Version) & OSVERSION_MASK)
76+
#define SPVER(Version) (((Version) & SPVERSION_MASK) >> 8)
77+
#define SUBVER(Version) (((Version) & SUBVERSION_MASK) )
78+
```
79+
80+
The **OSVER**, **SPVER**, and **SUBVER** macros can be used in your code to control conditional compilation for different levels of API support.
81+
82+
You may not see all of these versions of Windows listed in the *sdkddkver.h* that you're looking at. That means you're probably using an older version of the Windows SDK. By default, new Windows projects in Visual Studio use the Windows 10 SDK.
4283
4384
> [!NOTE]
4485
> Values are not guaranteed to work if you include internal MFC headers in your application.
Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,60 @@
11
---
2-
title: "How to: Use the Windows 10 SDK in a Windows Desktop Application"
2+
title: "How to: Use the Windows 10 SDK in a Windows Desktop application"
3+
description: "How to set the target SDK version in a Windows Desktop application project to use the Windows 10 SDK."
34
ms.custom: "get-started-article"
4-
ms.date: "07/12/2018"
5+
ms.date: "01/22/2020"
56
ms.assetid: eed6421e-9355-44a6-9582-3f1d453a6d44
67
---
7-
# How to: Use the Windows 10 SDK in a Windows Desktop Application
8+
# How to: Use the Windows 10 SDK in a Windows Desktop application
89

9-
When you create a classic Windows desktop project in Visual Studio 2017, it is set up by default to build with the version of the Windows 10 SDK that was installed when the C++ Desktop workload was installed or last updated. This version of the Windows SDK is compatible with Windows 7 and later. See [Using the Windows Headers](/windows/win32/WinProg/using-the-windows-headers) for more information about targeting specific versions of Windows.
10+
When you create a new classic Windows desktop project in Visual Studio, it targets the Windows 10 SDK by default. Visual Studio installs a version of this SDK when you install the C++ Desktop workload. The Windows 10 SDK supports writing code for Windows 7 SP1 and later. For more information about targeting specific versions of Windows, see [Using the Windows Headers](/windows/win32/WinProg/using-the-windows-headers) and [Update WINVER and _WIN32_WINNT](../porting/modifying-winver-and-win32-winnt.md).
1011

11-
If you want to target an earlier version of the SDK, you can open **Project | Properties** and choose from the other SDK versions available in the Windows SDK Version dropdown.
12+
When you upgrade an existing project, you have a choice: You can keep using the target Windows SDK specified in your project. Or, you can retarget your project to use the Windows 10 SDK. With the Windows 10 SDK, you get the advantages of support for the latest operating systems and language standards.
1213

13-
Starting with Visual Studio 2015 and the Windows 10 SDK, the CRT library was separated into two parts, one (ucrtbase) that contains the functions that are acceptable to be used in Universal Windows Apps, and one that contains everything else (vcruntime140). Since the Windows 10 SDK contains new functions, such as many C99 functions, you need to follow these steps in order to use those functions. See [CRT Library Features](../c-runtime-library/crt-library-features.md).
14+
## Use the right Windows SDK for your project
1415

15-
### To target the Windows 10 SDK
16+
Starting with Visual Studio 2015, the C Runtime (CRT) library was separated into two parts: One part, ucrtbase, contains the Standard C and Microsoft-specific CRT functions that you can use in Universal Windows Apps. This library is now known as the Universal CRT, or UCRT, and has moved into the Windows 10 SDK. The UCRT contains many new functions, such as C99 functions, needed to support the latest C++ language standards. The other part of the original CRT is vcruntime. It contains the C runtime support, startup, and termination code, and everything else that didn't go into the UCRT. The vcruntime library gets installed along with the C++ compiler and toolset in Visual Studio. For more information, see [CRT library features](../c-runtime-library/crt-library-features.md).
1617

17-
1. Make sure the Windows 10 SDK is installed. The Windows 10 SDK is installed as part of the **Desktop development with C++** workload. A standalone version is available at [Downloads and tools for Windows 10](https://developer.microsoft.com/windows/downloads).
18+
The UCRT is now a system component that's installed on every version of Windows 10. It's also available as an installable component for all earlier supported versions of Windows. You can use the Windows 10 SDK to target all the supported versions of Windows. For a complete list of supported operating systems, see [Windows 10 SDK](https://developer.microsoft.com/windows/downloads/windows-10-sdk).
1819

19-
2. Open the shortcut menu for the project node, and choose **Retarget SDK Version**.
20+
To retarget your projects to use the Windows 10 SDK when you upgrade from a project version before Visual Studio 2015, follow these steps:
2021

21-
![Retarget SDK Version](../windows/media/retargetingwindowssdk1.PNG "RetargetingWindowsSDK1")
22+
### To target the Windows 10 SDK
23+
24+
1. Make sure the Windows 10 SDK is installed. The Windows 10 SDK is installed as part of the **Desktop development with C++** workload. A standalone version is available at [Downloads and tools for Windows 10](https://developer.microsoft.com/windows/downloads).
2225

23-
The **Review Solution Actions** dialog appears.
26+
1. Open the shortcut menu for the project node, and choose **Retarget projects**. (In earlier versions of Visual Studio, choose **Retarget SDK Version**.) The **Review Solution Actions** dialog appears.
2427

2528
![Review Solution Actions](../windows/media/retargetingwindowssdk2.PNG "RetargetingWindowsSDK2")
2629

27-
3. In the **Target Platform Version** dropdown list, choose the version of the Windows 10 SDK you want to target. Choose the OK button to apply the change.
30+
1. In the **Target Platform Version** dropdown list, choose the version of the Windows 10 SDK you want to target. Generally speaking, we recommend you choose the latest installed version. Choose the **OK** button to apply the change.
2831

29-
Note that 8.1 in this context refers to the Windows SDK version, which is also backwardly compatible with Windows 8, Windows Server 2012, Windows 7, Windows Server 2008, and Windows Vista.
32+
The 8.1 in this context refers to the Windows 8.1 SDK.
3033

3134
If this step is successful, the following text appears in the Output window:
3235

3336
`Retargeting End: 1 completed, 0 failed, 0 skipped`
3437

35-
4. Open the project properties, and in the **Configuration Properties, General** section, notice the values of **Windows Target Platform Version**. Changing the value here has the same effect as following this procedure. See [General Property Page (Project)](../build/reference/general-property-page-project.md).
38+
1. Open the project properties dialog. In the **Configuration Properties** > **General** section, notice the values of **Windows Target Platform Version**. Changing the value here has the same effect as following this procedure. For more information, see [General Property Page (Project)](../build/reference/general-property-page-project.md).
3639

3740
![Target Platform Version](../windows/media/retargetingwindowssdk3.PNG "RetargetingWindowsSDK3")
3841

39-
This action changes the values of project macros that include paths to header files and library files. To see what changed, in the **Visual C++ Directories** section of the **Project Properties** dialog, choose one of the properties such as the **Include Directories**, choose to open the dropdown list, and choose \<Edit>. The **Include Directories** dialog appears.
42+
This action changes the values of project macros that include paths to header files and library files. To see what changed, open the **Visual C++ Directories** section of the **Project Properties** dialog. Select one of the properties, such as **Include Directories**. Then, open the property value's dropdown list, and choose **\<Edit>**. The **Include Directories** dialog appears.
4043

4144
![Include Directories dialog box](../windows/media/retargetingwindowssdk4.PNG "RetargetingWindowsSDK4")
4245

4346
Choose the **Macros >>** button, and scroll down the list of macros to the Windows SDK macros to see all the new values.
4447

4548
![Windows SDK Macros](../windows/media/retargetingwindowssdk5.PNG "RetargetingWindowsSDK5")
4649

47-
5. Repeat for other projects, as needed, and rebuild the solution.
50+
1. Repeat the retargeting procedure for other solution projects, as needed, and rebuild the solution.
4851

4952
### To target the Windows 8.1 SDK
5053

51-
1. Open the shortcut menu for the project node, and choose **Retarget SDK Version**.
54+
1. Open the shortcut menu for the project node in Solution Explorer, and choose **Retarget projects**. (In earlier versions of Visual Studio, choose **Retarget SDK Version**.)
5255

5356
2. In the **Target Platform Version** dropdown list, choose **8.1**.
5457

5558
## See also
5659

57-
[Windows Desktop Applications (Visual C++)](../windows/how-to-use-the-windows-10-sdk-in-a-windows-desktop-application.md)
60+
[Walkthrough: Create a traditional Windows Desktop application (C++)](../windows/walkthrough-creating-windows-desktop-applications-cpp.md)

0 commit comments

Comments
 (0)