Determining the Operating System Version

[Previous] [Next]

Once you've managed to get your device driver loaded—a feat that might require, as I've just discussed, arranging to define Windows 98 stubs for certain support routines—you may need to base run-time decisions on which version of the operating system happens to be in charge of the computer. You might want, for example, to call functions that aren't, strictly speaking, part of the WDM. IoReportTargetDeviceChangeAsynchronous, which I used in the PNPEVENT sample, is such a function.

It's very easy for an application to learn the operation system platform by calling GetVersionEx. The closest equivalent function in kernel mode is IoIsWdmVersionAvailable:

BOOLEAN IoIsWdmVersionAvailable(MajorVersion, MinorVersion);

Windows 2000 supports WDM version 1.10, which corresponds to the WDM_MAJORVERSION (1) and WDM_MINORVERSION (10) constants in the file WDM.H. Windows 98 (including Windows 98, Second Edition) supports WDM version 1.0 only. You can use this difference in support level to tell which platform you happen to be running on.

Other Heuristics for Operating System Version

I used to rely on different heuristics for determining the operating system version until experience and changes in the operating system made them obsolete. In the original retail release of Windows 98, for example, the DriverExtension of your driver object had a ServiceKeyName with zero length when the system invoked your DriverEntry in a normal way. Windows 2000, on the other hand, supplies a nonempty string for this parameter. So do later editions of Windows 98, which makes this heuristic useful only for detecting the original Windows 98.

Vireo Software used to suggest using the presence of a registry key named \Registry\Machine\SAM as an indicator for Windows 2000. This test isn't reliable for drivers that load during Windows 2000 startup, though, so you shouldn't rely on this test either. The company currently recommends a test based on the facts that the registry key HKLM\System\CurrentControlSet\Control\Class will exist in Windows 2000 but not Windows 98 and that the key HKLM\System\CurrentControlSet\Services\Class will exist in Windows 98 but not Windows 2000.



Programming the Microsoft Windows Driver Model
Programming the Microsoft Windows Driver Model
ISBN: 0735618038
EAN: 2147483647
Year: 1999
Pages: 93
Authors: Walter Oney

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net