Determining Windows Version, Mode from MS-DOS App

Last reviewed: July 23, 1997
Article ID: Q75338
3.10 WINDOWS kbprg

The information in this article applies to:

  • Microsoft Windows Software Development Kit (SDK) for Windows version 3.1

SUMMARY

The following assembly language code fragment can be used in an MS-DOS- based application to determine if it is running in a Windows MS-DOS window, and if so, which version and mode of Windows is running.

test_win proc near

; check for Windows 3.1

    mov     ax,160ah                ; WIN31CHECK
    int     2fh                     ; check if running under Win 3.1.
    or      ax,ax
    jz      RunningUnderWin31       ; can check if running in standard
                                    ; or enhanced mode

; check for Windows 3.0 enhanced mode

    mov     ax,1600h                ; WIN386CHECK
    int     2fh
    test    al,7fh
    jnz     RunningUnderWin30Enh    ; enhanced mode

; check for 3.0 WINOLDAP

    mov     ax,4680h                ; IS_WINOLDAP_ACTIVE
    int     2fh
    or      ax,ax                   ; running under 3.0 derivative?
    jnz     NotRunningUnderWin

; rule out MS-DOS 5.0 task switcher

    mov     ax,4b02h                ; detect switcher
    push    bx
    push    es
    push    di
    xor     bx,bx
    mov     di,bx
    mov     es,bx
    int     2fh
    pop     di
    pop     es
    pop     bx
    or      ax,ax
    jz      NotRunningUnderWin      ; MS-DOS 5.0 task switcher found

; check for standard mode Windows 3.0

    mov     ax,1605h                ; PMODE_START
    int     2fh
    cmp     cx,-1
    jz      RunningUnderWin30Std

; check for real mode Windows 3.0

    mov     ax,1606h                ; PMODE_STOP
    int     2fh                     ; in case someone is counting
    ; Real mode Windows 3.0 is running
    jmp     NotRunningUnderWin

RunningUnderWin30Std:

    ; Standard mode Windows 3.0 is running
    jmp     NotRunningUnderWin

RunningUnderWin31:

    ; At this point: CX == 3 means Windows 3.1 enhanced mode
    ;                CX == 2 means Windows 3.1 standard mode
    jmp     NotRunningUnderWin

RunningUnderWin30Enh:

    ; Enhanced mode Windows 3.0 is running

NotRunningUnderWin:

        ret

test_win endp

MORE INFORMATION

Applications for Windows should use the GetWinFlags() function to determine which version of Windows is running. For more information, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q131371
   TITLE     : Determining System Version from a Windows-Based Application


Additional reference words: 3.10
KBCategory: kbprg
KBSubcategory: KrWoa
Keywords : kb16bitonly


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: July 23, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.