Microsoft KB Archive/193824

From BetaArchive Wiki

HOWTO: Getting OS Version Information in a Device Driver

Q193824



The information in this article applies to:


  • Microsoft Win32 Device Driver Kit (DDK) for Windows NT, version 4.0





SUMMARY

There is no documented way to get operating system version information from a kernel-mode device driver. There is an API in NTDDK.h called PsGetVersion that returns the Major version, Minor version, Build number, and the CSD (Corrected Service Diskette, Service Pack) number.



MORE INFORMATION

Sample Code

The following code is from NTDDK.h:


   BOOLEAN
   PsGetVersion(
       PULONG MajorVersion OPTIONAL,
       PULONG MinorVersion OPTIONAL,
       PULONG BuildNumber OPTIONAL,
       PUNICODE_STRING CSDVersion OPTIONAL
       ); 


Typical code for a kernel-mode device driver might be as follows:


    BOOLEAN     success;
    ULONG       MajorVersion;
    ULONG       MinorVersion;
    ULONG       BuildNumber;
    UNICODE_STRING CSDVersion;

    success = PsGetVersion(
                 &MajorVersion,
                 &MinorVersion,
                 &BuildNumber,
                 &CSDVersion
                 ); 


All of the parameters are optional. If a parameter is not required by a device driver, replace it with NULL as follows:


    success = PsGetVersion(
                 &MajorVersion,
                 &MinorVersion,
                 NULL,
                 NULL
                 ); 


NOTE: The PsGetVersion API information is included in the Windows NT 5.0 DDK.

Keywords : _IK kbDDK kbKMode kbOSWinNT400
Issue type : kbhowto
Technology : kbAudDeveloper kbWinDDKSearch kbWin32sSearch kbWin32DDKSearch kbWin32DDKNT400 kbWin32DDKNTSearch


Last Reviewed: March 8, 1999
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.