How to properly include windows.h and set minimum version to XP

柔情痞子 提交于 2019-12-08 08:00:08

问题


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:


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>


来源:https://stackoverflow.com/questions/15601003/how-to-properly-include-windows-h-and-set-minimum-version-to-xp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!