判断操作系统的小技巧

判断操作系统的小技巧(来自WDK)

 
IoIsWdmVersionAvailable
The IoIsWdmVersionAvailable routine checks whether a given WDM version is supported by the operating system.

BOOLEAN
  IoIsWdmVersionAvailable(
    IN UCHAR  MajorVersion,
    IN UCHAR  MinorVersion
    );


Parameters
MajorVersion
Specifies the major version number of WDM that is requested.
MinorVersion
Specifies the minor version number of WDM that is requested.
Return Value
IoIsWdmVersionAvailable returns TRUE if the version of WDM that the operating system provides is greater than or equal to the version number of WDM being requested.

Comments
Drivers should use the RtlIsNtDdiVersionAvailable function instead of the IoIsWdmVersionAvailable function.

Cross-platform drivers should use this routine to check the WDM version before performing any operations that vary by platform or are not supported in all versions of WDM.

The constants WDM_MAJORVERSION and WDM_MINORVERSION are defined in wdm.h. The following lists the WDM version provided with each operating system.

Operating system WDM major version WDM minor version
Windows Vista 6 0x00
Windows Server 2003 1 0x30
Windows XP 1 0x20
Windows 2000 1 0x10
Windows Me 1 0x05
Windows 98 1 0x00


Note that the minor version number is defined as a hexadecimal value.

Later versions of WDM support all the features available in earlier versions of WDM; that is, each version of WDM is a superset of the previous WDM version.

The following call returns TRUE on any of the listed operating systems, because all these systems support all the features of WDM 1.0:

bVersion = IoIsWdmVersionAvailable(1,0);



The following example shows how a driver can dynamically detect the current operating system:

if (IoIsWdmVersionAvailable(1, 0x10)) {
    //
    //If WDM 1.10 is supported, this is Windows 2000
    //or better.
    //
} else if (IoIsWdmVersionAvailable(1, 5)) {
    //
    //If WDM 1.05 is supported, this is Windows ME
    //or better.
    //
} else {
    //
    //WDM 1.0 is always supported, so this is Windows 98,
    //Windows 98 SE, or better.
    //
}


As the example shows, calling IoIsWdmVersionAvailable(1, 5) returns TRUE on Windows Me, Windows 2000, and any succeeding operating systems, but FALSE on Windows 98 and Windows 98 SE.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值