错误 C1189: #error:此文件需要至少 #defined_WIN32_WINNT才能0x0500.建议使用0x

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

本文关键字:WIN32 才能 WINNT 0x0500 0x #defined #error C1189 文件 错误      更新时间:2023-10-16

我在VS2010(windows xp)中创建MFC项目。我接受这个错误:

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之类的用途。我需要用这个做什么?

我认为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中的标准不同。