=========================================================================== BBS: The Abacus * HST/DS * Potterville, MI Date: 06-03-93 (12:50) Number: 148 From: RICK PEDLEY Refer#: NONE To: ALL Recvd: NO Subj: Detecting Windoze Conf: (35) Quick Basi --------------------------------------------------------------------------- Here are a few functions I typed in from a copy of PC Mag someone may find useful; I've added a few comments here and there: 'WINFUNCS.BAS - Harry F. Harrison, PC Mag, 93-05-11, p394-396 'use QB.BI with Quick BASIC, and VBDOS.BI with VB4DOS DEFINT A-Z '$INCLUDE: 'QBX.BI' DECLARE FUNCTION WindowsActive% (Ver!) DECLARE FUNCTION GetCurrentWindowsVM% () SELECT CASE WindowsActive%(Ver!) CASE 0: PRINT "Neither Windows nor DOS Shell is active" CASE -1: PRINT "Windows 386 Enhanced mode is active, "; PRINT USING "Version #.##"; Ver! CASE 1: PRINT "DOS Shell is active" CASE 2: PRINT "Windows Standard mode is active" END SELECT PRINT "Windows Virtual Machine ID #:"; GetCurrentWindowVM% END SUB EndCriticalCode 'Re-enables Windows swapping after a call to StartCriticalCode DIM InRegsX AS RegTypeX, OutRegsX AS RegTypeX InRegsX.ax = &H1682 CALL InterruptX(&H2F, InRegsX, OutRegsX) END SUB FUNCTION GetCurrentWindowsVM% 'Gets the current Virtual Machine ID under Windows 'if multiple DOS sessions are running, this enables you 'to tell which one you're in and to assign unique file 'handles. DIM InRegsX AS RegTypeX, OutRegsX AS RegTypeX InRegsX.ax = &H1683 CALL InterruptX(&H2F, InRegsX, OutRegsX) GetCurrentWindowsVM% = OutRegsX.bx END FUNCTION SUB GiveUpTimeSlice 'Gives up the remainder of a time slice to Windows 'For example, your program is polling for a keypress and not 'doing anything useful -- gives CPU time back to multi-tasker. DIM InRegsX AS RegTypeX, OutRegsX AS RegTypeX InRegsX.ax = &H1680 CALL InterruptX(&H2F, InRegsX, OutRegsX) END SUB SUB StartCriticalCode 'Prevents Windows from swapping out or switch to another 'task while your program is performing a critical task. 'Use just before saving a file, for example. DIM InRegsX AS RegTypeX, OutRegsX AS RegTypeX InRegsX.ax = &H1681 CALL InterruptX(&H2F, InRegsX, OutRegsX) END SUB FUNCTION WindowsActive% (Ver!) 'determines whether Windows is active and if so, what version. DIM InRegsX AS RegTypeX, OutRegsX AS RegTypeX InRegsX.ax = &H1600 CALL InterruptX(&H2F, InRegsX, OutRegsX) IF (OutRegsX.ax AND &HFF <> 0) AND (OutRegsX.ax AND &HFF <> &H80) AND (OutRegsX. ax <> &H1600) THEN WindowsActive% = -1 Ver! = (((OutRegsX.ax AND &HFF) * 100) + OutRegsX.ax \ 256) / 100 ELSE InRegsX.bx = 0 InRegsX.di = 0 InRegsX.es = 0 InRegsX.ax = &H4B02 CALL InterruptX(&H2F, InRegsX, OutRegsX) IF OutRegsX.es OR OutRegsX.di THEN WindowsActive% = 1 IF LEN(ENVIRON$("windir")) THEN WindowsActive% = 2 'the above line differentiates between running in Windows 'Standard mode and running under DOS Shell. Note that `windir' 'must be lower case. END IF END FUNCTION ___ * OFFLINE 1.54 * Firengi scientist: sort of a contradiction in terms.. --- Maximus 2.01wb * Origin: BULLpen BBS * USR DS 16.8/FAX & ASL (613)549-5168 (1:249/140) SEEN-BY: 1/211 11/2 4 13/13 101/1 108/89 109/25 110/69 114/5 123/19 124/1 SEEN-BY: 153/752 154/40 77 157/110 159/100 125 430 575 950 203/23 209/209 SEEN-BY: 261/1023 280/1 390/1 396/1 15 397/2 2230/100 2440/5 3603/20