HOWTO: Getting OS Version Information in a Device Driver

ID: Q193824


The information in this article applies to:


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          : kbcode kbDDK kbKMode kbNTOS400 
Version           : 
Platform          : 
Issue type        : kbhowto 

Last Reviewed: March 6, 1999