How to properly include windows.h and set minimum

2019-05-30 19:24发布

I'm currently building a C++ DLL, and I have this at the top of the main DLL .cpp file. This currently is causing the warning "Warning C4005: '_WIN32_WINNT' : macro redefinition". What have I done wrong?

I need to include windows.h, SDKDDKVer.h and set the minimum windows version to XP. How do I correct my code?

// System Includes
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <d3d9.h>

// Windows Version
#define _WIN32_WINNT _WIN32_WINNT_WINXP
#include <SDKDDKVer.h>

1条回答
姐就是有狂的资本
2楼-- · 2019-05-30 19:56

You should include the SDK stuff first:

// Windows Version
#define _WIN32_WINNT 0x0501     // _WIN32_WINNT_WINXP
#include <SDKDDKVer.h>

// System Includes
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <d3d9.h>
查看更多
登录 后发表回答