Detecting Windows NT from an MS-DOS-Based Application

Last reviewed: December 17, 1996
Article ID: Q100290
The information in this article applies to:
  • Microsoft Win32 Software Development Kit (SDK), versions 3.1, 3.5, 3.51 and 4.00

SUMMARY

There are calls that MS-DOS-based applications can make that are not supported under Windows NT. For example, calling Interrupt 25h to read the disk is not supported under Windows NT. Therefore, in some cases MS-DOS- based applications will need to know whether or not they are running under Windows NT.

Interrupt 21h, function 3306h can be used by MS-DOS-based applications to detect whether or not they are running under Windows NT. On return, registers BL and BH will contain the operating system major and minor numbers, respectively. If your application is running under Windows NT, the return will be:

   BL = 5
   BH = 50

MORE INFORMATION

Note that it is important to check both BL and BH, because MS-DOS 5.0 will also return a 5 in BL.

The following code demonstrates how to detect the operating system version from an MS-DOS-based application:

Sample Code

#include <stdio.h>
#include <stdlib.h>
#include <io.h>

void main()
{
   unsigned char cbh = 0;
   unsigned char cbl = 0;

   _asm {
      mov ax, 3306h
      int 21h
      mov cbh, bh
      mov cbl, bl
   }
   printf( "After int 21h\n" );
   printf( "%u, %u (bh, bl)\n", cbh, cbl );
}


KBCategory: kbprg
KBSubcategory: SubSys
Additional reference words: 3.10 3.50 3.51 4.0 detect NT MS-DOS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: December 17, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.