'=========================================================================== ' Subject: RETURNS DOS VERSION NUMBER Date: 02-07-96 (20:00) ' Author: Mark K. Kim Code: QB, QBasic, PDS ' Origin: MarkKKim@aol.com Packet: DOS.ABC '=========================================================================== 'DOSVer version 1.0a -- Display DOS version number 'Copyright (c)1995-6 Mark K. Kim 'E-mail: MarkKKim@aol.com 'http://users.aol.com/markkkim/ '* Freely distributed. May be used in other programs with proper notice of ' credit. '* This program is provided "as-is". '* Not compatible with PowerBASIC. '* In QuickBASIC 4.5, run QB.EXE with /L option. If including QB.BI, then ' replace the ABSOLUTE SUB declaration statement in QB.BI with the ABSOLUTE ' SUB declaration within this program. Make other proper revisions. '* CREDIT: Ralf Brown's interrupt list was used to get interrupt for the ' function. Microsoft DOS's Debug was used to convert Assembly code to ' machine code. Microsoft is a Registered Trademark of Microsoft Corp. ' Thanks to beta testers, rt911@aol.com and wildgamer@aol.com 'Read the header of each function to find out the usage of those functions. 'These functions are designed to work with most other routines as it does 'not interfere with any other routines. It is especially designed to work 'with other functions in this BASxx series. DECLARE SUB absolute (var1%, var2%, var3%, var4%, var5%, var6%, offset%) '== BEGIN HEADER == DECLARE FUNCTION getdosver () '== END HEADER == '== START == PRINT "DOS Version:"; getdosver 'Returns DOS version as a single-precision number 'COMMENTS: '* It has not been fully tested on low DOS versions. Plus some exceptions ' apply (ie - IBM-DOS 6.1 reports itself as 6.0 because there never was ' IBM-DOS 6.0; there was MS-DOS 6.0 instead). It reports 7.0 on DOS that ' comes with Windows95. '* DOS version may be faked with special programs 'RETURN: '* DOS version as a single-precision number. (ie - 6.22) FUNCTION getdosver 'initialize machine language instructions asm$ = "" asm$ = asm$ + CHR$(&H55) 'push bp asm$ = asm$ + CHR$(&H89) + CHR$(&HE5) 'mov bp, sp asm$ = asm$ + CHR$(&HB8) + CHR$(&H0) + CHR$(&H30) 'mov ax, 3000 asm$ = asm$ + CHR$(&HCD) + CHR$(&H21) 'int 21 asm$ = asm$ + CHR$(&H8B) + CHR$(&H5E) + CHR$(&H6) 'mov bx, [bp+06] asm$ = asm$ + CHR$(&H89) + CHR$(&H7) 'mov [bx], ax asm$ = asm$ + CHR$(&H5D) 'pop bp asm$ = asm$ + CHR$(&HCA) + CHR$(&H2) + CHR$(&H0) 'retf 0002 'execute machine language instructions DEF SEG = VARSEG(asm$) 'set segment offset% = SADD(asm$) 'find offset CALL absolute(var1%, var2%, var3%, var4%, var5%, ax%, offset%) 'execute DEF SEG IF ax% > 1 THEN 'transfer ax integer to ax long integer ax& = ax% ELSEIF ax% < 0 THEN ax& = ABS(ax%) + &H8000 ELSE ax& = &H100 END IF majver% = ax& AND &HFF 'find major version minver% = (ax& AND &HFF00) / &H100 'find minor version getdosver = majver% + (minver% / 100) 'return values END FUNCTION