Please leave the window-installer tag in - this Q/A is not for C++ experts, but for people like me, who use C++ when they have to. They may face this potential time-waster, and need a quick fix to get
msi.h
or other includes operational quickly. VS2017 templates must have changed quite a bit - I didn't see this issue before.
Visual Studio 2017 Community Edition with all available C++ components installed (perhaps this problem does not exist in the professional edition?).
File => New => Project... => Visual C++\Windows Desktop\Windows Console Application => OK
.- Do a quick test build to verify there are no errors.
Right click solution => Build
. As stated no errors should show up. - Now add this include for msi.h directly below
#include stdafx.h
right above themain()
function in the console appliation's CPP file:
#include <msi.h>
// And just to make things link:
#pragma comment(lib, "msi.lib")
A red error chevron should show up in the top left corner at the start of the first line comment saying on hover: "There are too many errors for the IntelliSense engine to function correctly, some of which may not be visible in the editor. PCH warning: an unknown error occurred. An IntelliSense PCH file was not generated."
Doing a build now should reveal numerous errors. In my case from
wincrypt.h
- and it got me thinking aboutWIN32_LEAN_AND_MEAN
- see answer below. I thought such basics would already be included.
I keep seeing this problem in all new C++ Windows Console Application projects
, but when I try in an older project created with Visual Studio 2013
it compiles correctly with msi.h
included along with the link pragma.
Judging from the error message there must be something wrong with the precompiled header (PCH). This is what threw me off.