8

I create MFC project in VS2010(windows xp). And i take this error:

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

if I added in afxcomctl32.h: #define _WIN32_WINNT 0x0501, i take 60+ errors. In project i dont added anything. Use such as Visual Studio created. What i need to do with this?

4

4 回答 4

23

我认为 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
于 2013-02-01T10:15:27.100 回答
3

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

#include <sdkddkver.h>

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

_WIN32_WINNT=_WIN32_WINNT_WINXP

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

布莱赫。我讨厌为 Windows 编程。

于 2013-10-19T00:44:32.620 回答
1

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

应该管用。

于 2013-02-01T10:30:49.447 回答
0

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

于 2013-02-01T13:32:20.820 回答