使用某些Widows API时,明明包含了该头文件,却报错“error C2065: undeclared identifier”

2023-02-28,,

  在使用一些新版本的API,或者控件的新特性(比如新版的ComCtl32.dll)的时候,你可能会得到“error C2065: undeclared identifier.“这个错误。原因是这些功能是依赖于你的操作系统的版本的。而你的头文件中的定义并不是最新的。

  下面详细列举了每个Windows版本对应的NTDDI_VERSION,_WIN32_WINNT,WINVER,_WIN32_IE这些宏。

下表描述不同版本Windows头文件中推荐使用的宏

  Minimum system required          Macros to define 

  Windows Server                      NTDDI_VERSION >= NTDDI_LONGHORN
  Windows Vista NTDDI_VERSION >= NTDDI_VISTA
  Windows Server SP1 NTDDI_VERSION >= NTDDI_WS03SP1
  Windows Server 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 SP4 NTDDI_VERSION >= NTDDI_WIN2KSP4
  Windows SP3 NTDDI_VERSION >= NTDDI_WIN2KSP3
  Windows SP2 NTDDI_VERSION >= NTDDI_WIN2KSP2
  Windows SP1 NTDDI_VERSION >= NTDDI_WIN2KSP1
  Windows NTDDI_VERSION >= NTDDI_WIN2K

下表描述不同版本Windows头文件中使用的合法宏

  Minimum system required                 Macros to define
  
  Windows Server _WIN32_WINNT>=0x0600
WINVER>=0x0600
  Windows Vista _WIN32_WINNT>=0x0600
WINVER>=0x0600
  Windows Server _WIN32_WINNT>=0x0502
WINVER>=0x0502
  Windows XP _WIN32_WINNT>=0x0501
WINVER>=0x0501
  Windows _WIN32_WINNT>=0x0500
WINVER>=0x0500
  Windows NT 4.0 _WIN32_WINNT>=0x0400
WINVER>=0x0400
  Windows Me _WIN32_WINDOWS=0x0500
WINVER>=0x0500
  Windows _WIN32_WINDOWS>=0x0410
WINVER>=0x0410
  Windows _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, .0a, .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

使用某些Widows API时,明明包含了该头文件,却报错“error C2065: undeclared identifier”的相关教程结束。

《使用某些Widows API时,明明包含了该头文件,却报错“error C2065: undeclared identifier”.doc》

下载本文的Word格式文档,以方便收藏与打印。