关于关于_WIN32_WINNT的说明

来源:互联网 发布:软件特征码是什么 编辑:程序博客网 时间:2024/04/29 14:16
        在使用一些新版本的API,或者控件的新特性(比如新版的ComCtl32.dll)的时候,你可能会得到“error C2065: undeclared identifier.“这个错误。原因是这些功能是依赖于你的操作系统的版本的。而你的头文件中的定义并不是最新的。(对于MFC,就是stdafx.h)下面详细列举了每个Windows版本对应的NTDDI_VERSION_WIN32_WINNTWINVER_WIN32_IE这些宏。

 

The following table describes the preferred macros in use by the Windows header files.

Minimum system required                Macros to define
Windows Server 2008                     NTDDI_VERSION >= NTDDI_LONGHORN
Windows Vista                                NTDDI_VERSION >= NTDDI_VISTA
Windows Server 2003 SP1                 NTDDI_VERSION >= NTDDI_WS03SP1
Windows Server 2003                     NTDDI_VERSION >= NTDDI_WS03
Windows XP SP2                          NTDDI_VERSION >= NTDDI_WINXPSP2
Windows XP SP1                          NTDDI_VERSION >= NTDDI_WINXPSP1
Windows XP                                  NTDDI_VERSION >= NTDDI_WINXP
Windows 2000 SP4                        NTDDI_VERSION >= NTDDI_WIN2KSP4
Windows 2000 SP3                        NTDDI_VERSION >= NTDDI_WIN2KSP3
Windows 2000 SP2                        NTDDI_VERSION >= NTDDI_WIN2KSP2
Windows 2000 SP1                        NTDDI_VERSION >= NTDDI_WIN2KSP1
Windows 2000                                NTDDI_VERSION >= NTDDI_WIN2K

The following table describes the legacy macros in use by the Windows header files.

Minimum system required                 Macros to define
Windows Server 2008                      _WIN32_WINNT>=0x0600
                                                         WINVER>=0x0600
 
Windows Vista                            _WIN32_WINNT>=0x0600
                                                     WINVER>=0x0600
 
Windows Server 2003                      _WIN32_WINNT>=0x0502
                                                          WINVER>=0x0502
 
Windows XP                               _WIN32_WINNT>=0x0501
                                                       WINVER>=0x0501
 
Windows 2000                             _WIN32_WINNT>=0x0500
                                                      WINVER>=0x0500
 
Windows NT 4.0                           _WIN32_WINNT>=0x0400
                                                       WINVER>=0x0400
 
Windows Me                               _WIN32_WINDOWS=0x0500
                                                       WINVER>=0x0500
 
Windows 98                               _WIN32_WINDOWS>=0x0410
                                                   WINVER>=0x0410
 
Windows 95                               _WIN32_WINDOWS>=0x0400
                                                    WINVER>=0x0400
 
Internet Explorer 7.0                        _WIN32_IE>=0x0700
Internet Explorer 6.0 SP2                 _WIN32_IE>=0x0603
Internet Explorer 6.0 SP1                 _WIN32_IE>=0x0601
Internet Explorer 6.0                        _WIN32_IE>=0x0600
Internet Explorer 5.5                         _WIN32_IE>=0x0550
Internet Explorer 5.01                        _WIN32_IE>=0x0501
Internet Explorer 5.0, 5.0a, 5.0b          _WIN32_IE>=0x0500
Internet Explorer 4.01                       _WIN32_IE>=0x0401
Internet Explorer 4.0                          _WIN32_IE>=0x0400
Internet Explorer 3.0, 3.01, 3.02        _WIN32_IE>=0x0300


        另外,参见msdn上关于修改 WINVER和_WIN32_WINNT的说明:http://msdn.microsoft.com/zh-cn/library/6sehtctf


        Visual C++ 不再适用于 Windows 95、Windows 98、Windows ME 或 Windows NT。 如果您的 WINVER 或 _WIN32_WINNT 宏分配给了其中一个 Windows 版本,则必须修改相应宏。 当升级使用 Visual C++ 早期版本创建的项目时,如果 WINVER 或 _WIN32_WINNT 宏分配给了不再受支持的 Windows 版本,则会显示与这些宏相关的编译错误。

         若要修改相应宏,请在头文件中添加以下行。

         #define WINVER 0x0500
        #define _WIN32_WINNT 0x0500

        这是用于 Windows 2000 操作系统的值。 其他有效值包括 0x0501(用于 Windows XP)、0x0502(用于 Windows Server 2003)、0x0600(用于 Windows Vista)和 0x0601(用于 Windows 7)。

        如果您的应用程序中包括内部 MFC 头,则不能保证这些值能够正常工作。 例如,afximpl.h 中不支持 Windows 2000。还可以使用 /D 编译器选项定义此宏。 有关更多信息,请参见/D(预处理器定义)。有关这些宏的含义的更多信息,请参见使用 Windows 头文件。



0 0
原创粉丝点击