Visual Studio 2017 can't find windows.h

Hell'o I've just installed Visual Studio 2017 (enterprise).I opened my project whom I created in Visual Studio 2015. My project uses windows.h library but VS2017 cannot find this library. How to repair this?

Answers


My solution was :

  • Open the project properties
  • Into General --> SDK Version
  • I just picked the 10.0.15063.0 version instead of 8.1

And it worked.


I solved this issue by re-running the Visual Studio Installer and selecting the "Modify" button. Once presented with the Workloads screen I clicked on the "Individual Components" tab and selected all of the latest "Windows 10 SDK" Checkboxes(version 10.0.15063.0). My guess is that the entry for "Desktop C++ x86 and x64" is the one the actually fixes it but it is only speculation because none of those options were checked when I ran the installer and as you can see I checked all of them.


This happens when you have customized include/library paths in legacy projects. If you added your own additional paths in project properties, VisualStudio 2017 can't automatically figure out base paths when switching between platforms/toolsets - normally it automatically puts correct paths there, but if you added customizations, VS won't touch them.

This is legitimate problem which I ran into myself recently when migrating old project targeted for Windows XP into VS2017. None of the answers or comments listed/linked here so far are helpful. I have all legacy SDKs in VisualStudio 2017 installer, and none of that fixed VS not finding essential includes such as <windows.h>. In my case the project was using v120 toolset from VS2013, which is superseded by v140_xp in newer VS.

After setting correct platform and toolset understood by VS2017, I did the following to resolve the problem:

  • Open project properties, go to VC++ Directories, for 'Include Directories' and for 'Library Directories', choose <Inherit from parent or project defaults>. This will remove your additional paths.

  • Click 'Apply'. This will reset include path to something like $(VC_IncludePath_x86);$(WindowsSdk_71A_IncludePath_x86) (will vary for SDKs).

  • Re-add your extra paths here, or better yet - under C/C++/General -> Additional Include Directories and Linker/General -> Additional Library Directories.


If the installation was ok it should be here:

C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\um\Windows.h

So be sure it is on the include path of the project properties.

Or if you prefer by manual edit in the .vcxproj file at the IncludePath Tag line:

<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared;</IncludePath>

The problem occurs when you migrate your C++ project from a more updated visual studio version to a lesser one. To solve the issue simply go to your : Project's properties-->General-->SDK Version [and here unroll to show installed SDK versions so you downgrade to an available version {Since the required one seems unavailable hence the error}]. Once one of the Available SDKs selected, Apply, and go back to your code, and everything gonna get fixed.


I got it fixed when I simply changed "General => Windows SDK version" to a different version, submitted the changes and then changed it back.


You have to go in Visual Studio 2017 Installer, choose Individual Components, and manually select and install Windows 8.1 SDK.


This step work for me. 1. Open visual studio installer 2. at menu "Visual studio comunity 2017" --> click modify 3. at desktop development with c++ --> enable windows10 SDK for desktop and windows 8.1 SDK 4. click modify


I've also installed Visual Studio 2017 (community) first with the default composition settings.I opened my project whom I created in Visual Studio 2015. My project uses windows.h library but VS2017 cannot find this library and other problems. At first I install the missing (SDK 10 ... etc.) components. Part of problems is gone, but windows.h still not found. The problem was solved by completely uninstalling VS2017 and then installing with all the options at once.


My solution was checking paths.

Include Directories:

C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um;
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\shared;
%(AdditionalIncludeDirectories)

Library Directories:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64

and then right click Solution Explorer: Solution 'xxxxx' (1 project) line click "Retarget solution"

Remember to set Debug setting for Symbols fetch - Windows 10 must use Microsoft symbol server!


Need Your Help

Google maps removing controls

javascript html css google-maps

I am attempting to create a Google map of my company location. I used the link button on the Google maps page. Everything's fine, but when I shrink the map to 200 x 200 all the maps controls take o...

How to create checkbox inside dropdown?

javascript html css

I want to create a multiple selection dropbox list. Actually I have to select more than one option using a dropdown menu. When I simply do this as shown bellow: