ID Number: Q75943
3.00
WINDOWS
Summary:
An MS-DOS (non-Windows) application can determine whether it is
running within an MS-DOS session under Windows. This article provides
an assembly language program that demonstrates how this can be
accomplished.
More Information:
The following code determines whether Windows is running; if Windows
is running, the code determines what mode Windows is in and what
version of Windows is running.
Sample Code
-----------
.MODEL LARGE
.CODE
public _iswin
;
; Procedure to determine if in Windows or not.
; (From "Microsoft Systems Journal," March 1991, page 113)
; 0: Windows not running
; 1: Windows/386 2.x is running
; 3: Windows 3.x is in 386 enhanced mode
; 4: Windows 4.x is in 386 enhanced mode
; 127: Windows/386 2.x is running
; 128: Windows 3.0 is in real mode
; 255: Windows 3.0 is in standard mode
;
_iswin PROC FAR
MOV AX,4680H ;Is Windows 3.0 running?
INT 2FH
XOR AL,80H
MOV CL,AL
MOV AX,1600H ;Is Windows 3.x 386 enhanced mode
INT 2FH ;running?
AND AL,7FH
OR AL,CL
CMP AL,80H
JZ T1 ;Not Windows enhanced mode.
; Windows enhanced mode is running. At this point,
; AL contains the major version number of Windows
; and AH contains the minor version number.
; However, for this example, only the major version
; number is used.
JMP GOHOME ;Windows Enhanced, Go Home
T1: MOV AX,1605H ;Simulate Initialization.
XOR BX,BX
MOV ES,BX
XOR SI,SI
MOV DS,SI
XOR CX,CX
MOV DX,0001H ;MS-DOS extender
INT 2FH ;Windows real or Windows standard
CMP CX,+00
JNZ T2
MOV AX,1606H ;Simulate exit
INT 2FH
T2: MOV AL,80H
OR AL,CL
GOHOME:
MOV AH,4CH
INT 21H
_iswin ENDP
END
Additional reference words: 3.0