cannot open include file 'winresrc.h' - c++

Visual Studio 19, code (MFC) can be compiled on the machine if Platform Toolset is set to VS 2010 or VS 2017 but not if set to VS 2019 (V142). Which SDK do I need and where do I get it?

Open Visual Studio Installer and make sure if you have installed MFC, ATL and some Windows SDK. Check in the "Individual components". Note that MFC is not installed by default.

In the settings dialog of the project I set the SDK-Version to 'newest' (installed) and this fixed the problem.
I erroneously assumed that the SDK-Version was automatically set to the correct version when I changed the Platform Toolset.

Related

How can I set up Visual Studio 2017 to develop drivers?

According to this forum, https://answers.microsoft.com/en-us/windows/forum/windows_10-hardware-winpc/windows-wdk-on-visual-studio-2017-community/fdbd2b44-e57a-4849-903d-04001205a764
Windows Driver Kit is not currently supported by visual studio 2017.
I tried installing the Windows Driver Kit, but the test driver projects, such as this one, fail to build
https://github.com/Microsoft/Windows-driver-samples/tree/master/serial/VirtualSerial
I get this error when building:
Error MSB8020 The build tools for WindowsUserModeDriver10.0 (Platform Toolset = 'WindowsUserModeDriver10.0') cannot be found. To build using the WindowsUserModeDriver10.0 build tools, please install WindowsUserModeDriver10.0 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution".
I already tried retargeting the Solution to the two options I have: 10.0.17134.0 and 8.1, but the same error keeps coming up.
What do I need to do to build this sample driver? Do I need to install VS2015? VS2017 community edition? Why isn't this WDK supported by the Visual Studio 2017 professional version?
Thanks,
Visual Studio 2017 definitely supports kernel-mode device driver development; there's no doubt about that because I've been using VS17 for it for many, many months.
Use the latest version of Windows Driver Kit (WDK) which can be downloaded and installed from MSDN: https://learn.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk
Furthermore, you can always use the Enterprise WDK and then you can simply build using that if you wanted to from command-line. (Also can be found on page linked-to above)
Download the correct WDK installer for your edition of Visual Studio 2017:
WDK for Windows 10, version 1809 for Visual Studio Community 2017
WDK for Windows 10, version 1803 for Visual Studio Professional 2017
WDK for Windows 10, version 1709 for Visual Studio Enterprise 2017
Visit https://learn.microsoft.com/en-us/windows-hardware/drivers/other-wdk-downloads for more information.
Not exactly a solution, but Windows 8.1 WDK works with Visual Studio 2017 Enterprise,
Download it from here, just need to retarget the project to 8.1
https://www.microsoft.com/en-us/download/confirmation.aspx?id=42273
In addition, I needed to get VS2015 C++ Build Tool to fix a missing Microsoft.cpp.props error
http://download.microsoft.com/download/5/F/7/5F7ACAEB-8363-451F-9425-68A90F98B238/visualcppbuildtools_full.exe
Developing drivers to windows is quite interesting one will be exposed to advanced Operating System Concepts.The set up for the environment will be IDE
IDE - Visual Studio (https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community&rel=16)
Compilers (WDK)
Debugger (WDK)
WDK contains both(https://go.microsoft.com/fwlink/?linkid=2085767). Latest Visual Studio(VS2019) will come along with the latest WDK(10, 1903 as of now).
Sometimes plugins might not work properly i.e integration issues between Visual Studio and WDk.
By going to the location "C:\Program Files (x86)\Windows Kits\10\Vsix\VS2019" and run VSIX installer.
Now in a new project, driver related templates are available.

ATL is not working when migrating to Visual Studio 2015

I have a project which uses an ATL component to create pie charts. It's working fine in Visual Studio 2010 but when I migrate it to Visual Studio 2015, its not working or not instantiated. It's crashing at runtime
I have installed VS 2015 with the C++ support on Windows 7.
I have set the platform toolset to v140.
I have installed the VS 2015 x86 redistributable package .
Target platform version 8.1.
Tried adding ATL support in existing MFC project by ATL wizard. This causes crash in ATL (_pModule == 0) and some Dlls also not registered due to this change so I had to revert the changes.
Why do you add ATL again support?
As far as I understand your question this is an existing project and has ATL support! The ASSERT simply tells you that you have two ATL modules.

Can't change Windows SDK version in Visual Studio C++ project

I have a Visual Studio C++ console application that I created with Visual Studio 2015 and now I can't compile it (with Visual Studio 2017) because it is targeting the Windows 8.1 SDK, which is not installed. The problem is that I can't retarget the project to the Windows 10 SDK.
What happens is that when I open the project properties page and go to General - Target Platform I see the Windows 10 SDK in the dropdown, and I am able to select it... but as soon as I press Apply, it reverts back to 8.1 by itself. No error message is provided.
Visual Studio installer says that, indeed, the listed SDK version is installed:
So what's going on here? Is there a way to retarget my project without having to install the Windows 8.1 SDK?
Not sure if that matters but: this project is actually just a "wrapper" around an existing bare project consisting of just a bunch of .cpp and .h files, which was developed by another person. I'm really not familiar with C++ development.
After hours of struggling with this problem, I coincidentally discovered that selecting Project Properties/General, changing "Platform Toolset" to v141_xp (instead of v141) forcibly drops the Windows SDK Version to 8.1 or 7.0. I'm not sure how Visual Studio chooses which SDK to use.
EDIT: You must edit .vcxproj and change both:
<TargetPlatformVersion>10.0.17134.0</TargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>

how to forece mfc to use Redistributable 2013 or below

I create an Activex by vs2015 and '/clr' option. when i run it on other pc's, it need Redistributable 2015.
But Redistributable 2015 not installed on win8.1 and win2012 server. but Redistributable 2013 installed on them.
How can i force mfc to use Redistributable 2013? (or better solution)
i checked this but not helpful.
and changing Platform Toolset to Visual Studio 2015 - Windows XP (v140_xp), generate some errors in a hello-word project
i use Activex because i need events
it use 'clr' option, because i use a managed dll in this activex
Redistributable 2015 log Error 0x80240017: Failed to execute MSU package apparently for Windows8.1-KB2999226-x64.msu
Windows8.1-KB2999226-x64.msu standalone installer say The update is not applicable to your computer.
installing a Net4.6 suggested, But this installer blocked by The update corresponding to KB2919355 needs to be installed before you can install this product on Windows 8.1 or Windows Server 2012 R2 and this update is 690.8 MB, and that MB blocked me.
You can not switch Visual Studio to use older toolset. You have to either - install older version of MSVC, or link your program statically, removing need in the redistributable altogether. To staticaly link your project open its Release properties, navigate to the C++/Code generation node and select Multithreaded instead of Multithreaded Dll for the Runtime option.

Afx Unsupported in Windows 10/ Visual Studio 2015

I retargeted an MFC solution from Visual Studio 2013 to Visual Studio 2015, but when I built it I received an error telling me the compiler could not find afxdisp.h normally found under VC->atlmfc->include . -- Of course I copied the file from the VS 2013 location, but I was wondering why it was missing? Does anyone know?
My mistake, MFC is an addon in VS, and I did not have all of it (only had ATL). I relaunched installer went to custom install and clicked MFC classes. I also installed the Multibyte MFC library from the Visual Studio Website. It is not available in the custom options.