错误C1189:#error:该文件需要_WIN32_WINNT至less定义为0x0500。 build议使用0x0501或更高的值

我在VS2010中创buildMFC项目(Windows XP)。 我拿这个错误:

error C1189: #error : This file requires _WIN32_WINNT to be #defined at least to 0x0500. Value 0x0501 or higher is recommended. 

如果我添加afxcomctl32.h#define _WIN32_WINNT 0x0501 ,我采取60 +错误。 在项目中,我没有添加任何东西。 使用如Visual Studio创build。 我需要做什么呢?

afxcomctl32.h是一个错误的地方,我认为,要解决这个问题,使你的stdafx.h看起来像这样:

 // Modify the following defines if you have to target a platform prior to the ones specified below. // Refer to MSDN for the latest info on corresponding values for different platforms. #ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later. #define WINVER 0x0501 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. #endif #ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later. #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. #endif #ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. #define _WIN32_WINDOWS 0x0501 // Change this to the appropriate value to target Windows Me or later. #endif #ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later. #define _WIN32_IE 0x0500 // Change this to the appropriate value to target IE 5.0 or later. #endif 

尝试添加到您的StdAfx.h文件的顶部:

 #include <sdkddkver.h> 

在我的应用程序中,我正在定义

 _WIN32_WINNT=_WIN32_WINNT_WINXP 

起初我有同样的问题。 我发现,因为当你使用MFC,你不允许包含windows.h,_WIN32_WINNT_WINXP 永远不会被定义 ,所以_WIN32_WINNT没有一个有效的值。 通过包含windows.h用于定义这些值的标头(sdkddkver.h),突然间一切正常!

布莱什。 我讨厌Windows编程。

您不需要修改afxcomctl32.h。 你只需要在这个文件之前包含Windows.h。

应该管用。

我解决了我的问题。 事实是, atmcore.h文件与VS2010中的标准文件不同。