pengyou28
驱动牛犊
驱动牛犊
  • 注册日期2006-03-17
  • 最后登录2012-03-23
  • 粉丝0
  • 关注0
  • 积分5分
  • 威望23点
  • 贡献值0点
  • 好评度9点
  • 原创分0分
  • 专家分0分
阅读:2664回复:2

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

楼主#
更多 发布于:2008-09-18 14:20
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.
wowocock
VIP专家组
VIP专家组
  • 注册日期2002-04-08
  • 最后登录2016-01-09
  • 粉丝16
  • 关注2
  • 积分601分
  • 威望1651点
  • 贡献值1点
  • 好评度1227点
  • 原创分1分
  • 专家分0分
沙发#
发布于:2008-09-19 09:18
RtlGetVersion才是王道,2K下简朴点用PsGetVersion
typedef struct _OSVERSIONINFOEXW {
  ULONG  dwOSVersionInfoSize;
  ULONG  dwMajorVersion;
  ULONG  dwMinorVersion;
  ULONG  dwBuildNumber;
  ULONG  dwPlatformId;
  WCHAR  szCSDVersion[ 128 ];     // Maintenance string for PSS usage
  USHORT  wServicePackMajor;
  USHORT  wServicePackMinor;
  USHORT  wSuiteMask;
  UCHAR  wProductType;
  UCHAR  wReserved;
} RTL_OSVERSIONINFOEXW;
花开了,然后又会凋零,星星是璀璨的,可那光芒也会消失。在这样 一瞬间,人降生了,笑者,哭着,战斗,伤害,喜悦,悲伤憎恶,爱。一切都只是刹那间的邂逅,而最后都要归入死亡的永眠
Fuwaxy
驱动牛犊
驱动牛犊
  • 注册日期2006-11-01
  • 最后登录2009-06-22
  • 粉丝0
  • 关注0
  • 积分3分
  • 威望28点
  • 贡献值0点
  • 好评度24点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2008-09-23 19:15
乡楼上学习
驱网无线,快乐无限
游客

返回顶部