4

I'm new to C++ and I just got Visual Studio Community 2017. I don't quite know what workflow to use, so I went with my gut.

When I try to include windows.h using #include <windows.h>, I get a squiggly line underneath, and when I hover over, it says

cannot open source file "windows.h"

This is the same with conio.h and stdio.h.

Screenshot

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Jacob
  • 409
  • 6
  • 22
  • Workflow shouldn't matter. What does matter is whether or not you had C++ selected during the installation process. I think it might have an option for the windows sdk as well, but I don't remember. If it were me, I'd try uninstallling everything visual studio related, reboot, try install again, and see if that changes things. Also, make sure you are working on a win32 console project when you created new project. – Christopher Pisz Jun 28 '18 at 20:30
  • Possible duplicate of [Visual Studio 2017 can't find windows.h](https://stackoverflow.com/questions/43410631/visual-studio-2017-cant-find-windows-h) – Stevoisiak Jul 06 '18 at 15:18

2 Answers2

11

I seem to have found the issue

Solved!

  1. Click Project (top)

  2. Click properties (bottom)

  3. Under configuration properties, Click General

  4. Under general, click windows SDK version. If it is at 10.x put it to 8.1 then close then put it back to 10.x again.

Seemed to work for me.

Jacob
  • 409
  • 6
  • 22
  • 2
    You are going to want to use Windows 10 SDK, not 8.1 This would indicate that you did not install the windows sdk as part of the installation process. I'd go into add/remove programs or features, select Visual Studio and hit modify, then look for the option to install the windows 10 SDK – Christopher Pisz Jun 28 '18 at 20:57
  • 1
    @Christopher Pisz He/She said that they put it back to the Windows 10 SDK afterwards. – ImmortaleVBR Jun 28 '18 at 21:12
  • 1
    Wierd. I'd be curious if it actually links when you call something from the windows api. – Christopher Pisz Jun 28 '18 at 21:16
0

I solved the include issue by right click the project in the solution explorer and clickproperties, you would see properties tab, in the tab change the

  1. SDK from 8.1 to 10.X
  2. Platform toolset to Microsoft Visual Studio 2017(v141)

This works for me