'=========================================================================== ' Subject: DETECT OPERATING SYSTEM Date: 10-23-97 (23:08) ' Author: Jack Hudgions Code: QB, PDS ' Origin: FidoNet QUIK_BAS Echo Packet: DOS.ABC '=========================================================================== '| I have a vague memory of someone posting some code in this echo '| which detected the operation system currently in use, e.g. DOS 6.0 '| Win95 etc.. 'Here's what I've posted before... I've not improved it to recognize 'Windows 95 yet. 'These routines assume the declarations for the interrupt structures are 'present (QB.BI or QBX.BI), and that the QB.QLB or QBX.QLB quick library 'is loaded for use in the IDE (QB /L or QBX /L), or you're linking in the 'QB.LIB or QBX.LIB library when compiling. 'First off, make sure you include the file containing the interrupt 'structures, and dimension the variables needed by the CALL INTERRUPT 'routine: '$INCLUDE: 'qb.bi' 'change to qbx.bi for PDS. DIM InReg AS RegType, OutReg AS RegType 'You can change the DIM to DIM SHARED to make the variables available 'globally if you plan to place this code into SUBs or FUNCTIONs. 'Okay, now on to the real code... For Windows and OS/2, you'll need to 'retrieve the DOS version: ' Get DOS version InReg.AX = &H3306 CALL Interrupt(&H21, InReg, OutReg) DOSver = ((OutReg.BX AND 255) * 100) + (OutReg.BX \ 256) IF DOSver = 0 THEN InReg.AX = &H3000 CALL Interrupt(&H21, InReg, OutReg) DOSver = ((OutReg.AX AND 255) * 100) + (OutReg.AX \ 256) END IF 'This returns the version as an integer for simplicity (300 = DOS 3.00, '620 = DOS 6.20, etc.). 'Next, call the following function to detect Windows (If you attempt to 'execute this code under DOS 2.x, it will lock up): ' Check for Windows IF DOSver >= 300 THEN InReg.AX = &H160A CALL Interrupt(&H2F, InReg, OutReg) IF OutReg.AX <> 0 THEN WinMode = 0 ELSE WinMode = OutReg.CX END IF END IF 'The variable WinMode will be set as follows: ' 0 = Windows not detected ' 1 = Real mode detected (Win 3.0 and earlier only) ' 2 = Standard mode detected. (Win 3.11 and earlier only) ' 3 = 386 enhanced mode detected. 'For OS/2, check the DOS version, and if it's 20 or higher, your program 'is running under OS/2 2.0 or later: ' Check for OS/2 by checking if DOS ver >= 20. 'IsOS2 = DOSver >= 2000 'The variable IsOS2 will be zero (false) if OS/2 is not detected, or -1 '(true) if OS/2 is detected. You can also use the DOS version to 'determine the OS/2 version. I believe these are correct: ' OS/2 version DOS version returned ' 2.0 20.0 ' 2.1 20.1 ' 2.11 20.2 ' 3.0 20.3