# Troubles with Windows target versions

I recently migrated an old VC++ project to use the Visual Studio 2017 toolset and when compiling I run into the following errors about redefining the structure tagTOUCHINPUT:

The tagTOUCHINPUT is defined as follows in WinUser.h

However, afxwin.h also defines it as shown below:

The first defines it if WINVER is specifying at least Windows Vista, the second if NTDDI_VERSION is less than Windows 7. Looking in stdafx.h I could see the following definitions:

It looked like NTDDI_VERSION was missing so I defined it to refer to Windows 7.

With this, the previous compiling errors were gone, but a new error appeared:

The InitializeCriticalSectionEx requires minimum Windows Vista and Windows Server 2008 respectively. However, the _WIN32_WINNT and _WIN32_WINDOWS were defined to Windows XP. To fix the problem, I changed them both to 0x0601 to indicate Windows 7. And that fixed all compiler errors.

This site uses Akismet to reduce spam. Learn how your comment data is processed.