'=========================================================================== ' Subject: RETURNS WINDOWS VERSION Date: 02-07-96 (20:00) ' Author: Mark K. Kim Code: QB, QBasic, PDS ' Origin: MarkKKim@aol.com Packet: MISC.ABC '=========================================================================== 'BASWinVer version 1.0a -- Find out Windows Version '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 winver! () '== END HEADER == '== START == PRINT USING "##.##"; winver 'Returns the version of Windows 'COMMENT: '* Returns only if the program is run under Windows. 'RETURN: '* Returns the version of Windows. '* Returns 0 if Windows is not running. '* Returns 4.0 under Windows95 (This was not intentional, but that's what ' beta test showed). A beta tester said it's supposed to return 3.95 but it ' didn't... oh well. FUNCTION winver! asm$ = "" asm$ = asm$ + CHR$(&H55) 'push bp asm$ = asm$ + CHR$(&H89) + CHR$(&HE5) 'mov bp, sp asm$ = asm$ + CHR$(&HB8) + CHR$(&HA) + CHR$(&H16) 'mov ax, 160a asm$ = asm$ + CHR$(&HCD) + CHR$(&H2F) 'int 2f asm$ = asm$ + CHR$(&H3D) + CHR$(&H0) + CHR$(&H0) 'cmp ax, 0000 asm$ = asm$ + CHR$(&H75) + CHR$(&H17) 'jnz 0124 asm$ = asm$ + CHR$(&HBA) + CHR$(&H0) + CHR$(&H0) 'mov dx, 0000 asm$ = asm$ + CHR$(&H89) + CHR$(&HD8) 'mov ax, bx asm$ = asm$ + CHR$(&H88) + CHR$(&HE2) 'mov dl, ah asm$ = asm$ + CHR$(&H8B) + CHR$(&H5E) + CHR$(&H8) 'mov bx, [bp+08] asm$ = asm$ + CHR$(&H89) + CHR$(&H17) 'mov [bx],dx asm$ = asm$ + CHR$(&H88) + CHR$(&HC2) 'mov dl, al asm$ = asm$ + CHR$(&H8B) + CHR$(&H5E) + CHR$(&H6) 'mov bx, [bp+06] asm$ = asm$ + CHR$(&H89) + CHR$(&H17) 'mov [bx], dx asm$ = asm$ + CHR$(&H5D) 'pop bp asm$ = asm$ + CHR$(&HCA) + CHR$(&H4) + CHR$(&H0) 'retf asm$ = asm$ + CHR$(&HB8) + CHR$(&H0) + CHR$(&H16) 'mov ax, 1600 asm$ = asm$ + CHR$(&HCD) + CHR$(&H2F) 'int 2f asm$ = asm$ + CHR$(&H3C) + CHR$(&H1) 'cmp al, 01 asm$ = asm$ + CHR$(&H74) + CHR$(&H19) 'jz 0146 asm$ = asm$ + CHR$(&H3C) + CHR$(&H80) 'cmp al, 80 asm$ = asm$ + CHR$(&H74) + CHR$(&H1A) 'jz 014b asm$ = asm$ + CHR$(&HBA) + CHR$(&H0) + CHR$(&H0) 'mov dx, 0000 asm$ = asm$ + CHR$(&H88) + CHR$(&HC2) 'mov dl, al asm$ = asm$ + CHR$(&H8B) + CHR$(&H5E) + CHR$(&H8) 'mov bx, [bp+08] asm$ = asm$ + CHR$(&H89) + CHR$(&H17) 'mov [bx], dx asm$ = asm$ + CHR$(&H88) + CHR$(&HE2) 'mov dl, ah asm$ = asm$ + CHR$(&H8B) + CHR$(&H5E) + CHR$(&H6) 'mov bx, [bp+06] asm$ = asm$ + CHR$(&H89) + CHR$(&H17) 'mov [bx], dx asm$ = asm$ + CHR$(&H5D) 'pop bp asm$ = asm$ + CHR$(&HCA) + CHR$(&H4) + CHR$(&H0) 'retf 0004 asm$ = asm$ + CHR$(&HB8) + CHR$(&H2) + CHR$(&H0) 'mov ax, 0002 asm$ = asm$ + CHR$(&HEB) + CHR$(&HE6) 'jmp 0131 asm$ = asm$ + CHR$(&HB8) + CHR$(&H0) + CHR$(&H0) 'mov ax, 0000 asm$ = asm$ + CHR$(&HEB) + CHR$(&HE1) 'jmp 0131 asmseg% = VARSEG(asm$) asmoff% = SADD(asm$) DEF SEG = asmseg% CALL absolute(var1%, var2%, var3%, var4%, majver%, minver%, asmoff%) DEF SEG IF majver% = 0 THEN minver% = 0 winver! = majver% + (minver% / 100!) END FUNCTION