Windows platform sdk 头文件的使用

Windows Platform SDK在不同版本的系统间存在功能差异,通过宏定义如WINVER来决定提供哪些功能。例如,SM_CMONITORS等多显示器API在WINVER低于0x0500的系统中不可用。当编译器报错找不到相关符号时,可能是因为SDK不支持所定义的目标系统,需调整WINVER的值以匹配或升级目标系统版本。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

SDK的使用有些需要注意的地方:
例如Microsoft Platform SDK, August 2001 Edition版本的SDK,他的目标系统是Microsoft Windows® 95, Microsoft Windows NT® 4.0, Microsoft Windows® 98, Microsoft Windows Millennium Edition (Windows Me), Microsoft Windows 2000, Microsoft Windows XP, and Microsoft Windows .NET Server 。 如果你写的程序准备在Win 95上运行,但是使用了Win 98才有的特性,那么该程序在Win 95上运行时就会出问题。 所以SDK必须对程序的目标平台加以评估,决定是否可以提供相应功能给用户。 SDK通过宏来实现这个目标,给不同的系统定义不同的数字,这样你在VC中用宏定义程序的目标运行平台,SDK根据你的定义决定开放哪些功能。 

SDK使用下面的方法决定提供哪些功能:

Guard StatementMeaning
#if _WIN32_WINNT >= 0x0400Windows NT 4.0 and later. It is not implemented in Windows 95.
#if _WIN32_WINDOWS >= 0x0410Windows 98. The image may not run on Windows 95.
#if _WIN32_WINDOWS >= 0x0490Windows Me. The image may not run on Windows 95/98, Windows NT, or Windows 2000.
#if _WIN32_WINNT >= 0x0500Windows 2000. The image may not run on Windows 95/98 or Windows NT.
#if _WIN32_WINNT >= 0x0501Windows XP. The image may not run on Windows 95/98, Windows NT, Windows Me, or Windows 2000.
#if _WIN32_IE >= 0x0300Internet Explorer 3.0 and later.
#if _WIN32_IE >= 0x0400Internet Explorer 4.0 and later.
#if _WIN32_IE >= 0x0401Internet Explorer 4.01 and later.
#if _WIN32_IE >= 0x0500Internet Explorer 5.0 and later.
#if _WIN32_IE >= 0x0501Internet Explorer 5.01 and later.
#if _WIN32_IE >= 0x0560Internet Explorer 6.0 and later
#if _WIN32_IE >= 0x0600Internet Explorer 6.0 and later

平台定义如下,需要在代码中加上下面某个宏定义指定你的目标平台是哪个:

Minimum System RequiredMacros to Define
Windows 95 and
Windows NT 4.0
WINVER=0x0400
Windows 98 and
Windows NT 4.0
_WIN32_WINDOWS=0x0410 and WINVER=0x0400
Windows NT 4.0_WIN32_WINNT=0x0400 and WINVER=0x0400
Windows 98_WIN32_WINDOWS=0x0410
Windows 2000_WIN32_WINNT=0x0500 and WINVER=0x0500
Windows Me_WIN32_WINDOWS=0x0490
Windows XP and
Windows .NET Server
_WIN32_WINNT=0x0501 and WINVER=0x0501
Internet Explorer 3.0, 3.01, 3.02_WIN32_IE=0x0300
Internet Explorer 4.0_WIN32_IE=0x0400
Internet Explorer 4.01_WIN32_IE=0x0401
Internet Explorer 5.0, 5.0a, 5.0b_WIN32_IE=0x0500
Internet Explorer 5.01, 5.5_WIN32_IE=0x0501
Internet Explorer 6.0_WIN32_IE=0x0560 or
_WIN32_IE=0x0600


例如:
Win98之前的系统不提供多显示器相关API
SDK中有相应的定义,表示只有Win 98以上的系统可以使用下面的内容:
#if(WINVER   >=   0x0500)  
  #define   SM_XVIRTUALSCREEN               76  
  #define   SM_YVIRTUALSCREEN               77  
  #define   SM_CXVIRTUALSCREEN             78  
  #define   SM_CYVIRTUALSCREEN             79  
  #define   SM_CMONITORS                         80  
  #define   SM_SAMEDISPLAYFORMAT         81   
#endif   /*   WINVER   >=   0x0500   */  

如果你的程序打算在Win95上运行,程序定义了 #define WINVER=0x0400。那么使用SM_CMONITORS时,编译器就会报错,说找不到该符号。 

提示: 使用了Windows宏,如果编译器报告找不到定义,那么可能就是SDK对你定义的目标系统不提供支持,你需要在程序中提高你目标系统的定义,例如#define WINVER 0x0500,这样就可以使用编译通过了!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值