Perhaps You need to Retarget Projects Windows SDK version.
- Open the project properties
- Into General --> SDK Version
Here are More Possible Solutions.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am new to windows programming. I was following this guide on learning how to create windows program
but I'm having a problem with including Windows.h
It doesn't seem to do anything.
for example when I try to use any variable type defined in this header like HINSTANCE
or use functions like GetTimeZoneInformation
defined in timezoneapi.h
which should be included within Windows.h
But, when I explicitly include any child header like timezoneapi.h
individually it works.
for example
#include <Windows.h>
int main()
{
TIME_ZONE_INFORMATION New;
GetTimeZoneInformation(&New);
}
the above code gives me a lot of undefined errors
but this code
#define _X86_
#include <timezoneapi.h>
int main()
{
TIME_ZONE_INFORMATION New;
GetTimeZoneInformation(&New);
}
compiles and runs successfully.
I am using VS2017 version 15.9.36 With Windows 10 SDK (10.0.17134.0) My installed Packages
Edit:
I tried using VSCode to use Windows.h
with this extension and It compiles fine in the cmd with g++ version 5.3.0
I hope it gives some info about where exactly is the problem.
Edit2:
I included the Windows.h
file of Mingw that I tried in VSCode and it worked (with needing to explicitly define X86 and I get a lot of the same warning referring to VS "Windows.h" warning C4821: Unable to determine Unicode encoding type, please save the file with signature (BOM)
)
so the problem is in the VS file.
so When I opened both and compared them (They were a little different) I found out that there were preprocessor definitions conditions that prevented nearly all the includes in the file.
There were a lot of conditions there about RC_INVOKED
so I couldn't figure out which condition exactly caused it.
I would be glad if anyone can help figure out what is causing the problem in the file as I don't know if I can post anything from it here as it is copyrighted.
I would like to thank all the people that tried to help me.
Perhaps You need to Retarget Projects Windows SDK version.
Here are More Possible Solutions.
The error message says Unicode encoding type and it says BOM. So yes the error C4821
is the problem; see Compiler Warning (level 1) C4821. See How to: Save and open files with encoding. The following shows what one of my files has, it is the default.
What appears to be happening is that there is a couple (a few or whatever) bytes at the beginning of the file that you do not see that are confusing VS; or maybe it is the absence of that. So when you put the #define _X86_
at the beginning of the file that makes it possible for VS to use the #include
after it. Probably if you put a comment at the beginning then #include <Windows.h>
after that it would work. A better solution is to save the file so that VS is not confused.