'=========================================================================== ' Subject: DETECT WINDOWS ENHANCED MODE Date: 10-01-98 (21:46) ' Author: Leandro Pardini Code: QB, QBasic, PDS ' Origin: lpardini@cefex.com Packet: MISC.ABC '=========================================================================== '======================================== = ' May 1992 ' This demo shows you how to detect Windows, and how to prevent ' the user to swap out. It'll only detect Windows Enhanced mode ' and not Windows Standard Mode; however StartCriticalCode and ' EndCriticalCode WILL work in Standard Mode. '--------------------------------------------------------------- ' Oct 1998 ' Today I found this thing in my harddisk and checked it under ' Windows 98; it works perfectly. Maybe someone's can find this ' useful... '=============================================================== '$STATIC DEFINT A-Z DECLARE FUNCTION WindowsActive% () DECLARE SUB EndCriticalCode () DECLARE SUB StartCriticalCode () Version% = WindowsActive% IF Version% = 0 THEN PRINT "Windows isn't active." ELSE CLS PRINT USING "Windows version #.## is active."; Version% / 100 PRINT STRING$(60, 205) PRINT "Press any key to StartCriticalCode." WHILE INKEY$ = "": WEND CALL StartCriticalCode PRINT "Now you can't swap out to Windows." PRINT STRING$(60, 205) PRINT "Press any key to EndCriticalCode." WHILE INKEY$ = "": WEND CALL EndCriticalCode PRINT "Now you can swap out to Windows." PRINT STRING$(60, 205) PRINT "Press any key to end this demo." WHILE INKEY$ = "": WEND END IF '======================================== = ' Reenables Windows swapping after a call to StartCriticalCode. '=============================================================== SUB EndCriticalCode DIM Asm AS STRING * 6 MID$(Asm, 1, 6) = CHR$(184) + MKI$(5762) + CHR$(205) + CHR$(47) + CHR$(203) DEF SEG = VARSEG(Asm): CALL ABSOLUTE(VARPTR(Asm)): DEF SEG END SUB '======================================== = ' Prevents Windows from swapping out. '=============================================================== SUB StartCriticalCode DIM Asm AS STRING * 6 MID$(Asm, 1, 6) = CHR$(184) + MKI$(5761) + CHR$(205) + CHR$(47) + CHR$(203) DEF SEG = VARSEG(Asm): CALL ABSOLUTE(VARPTR(Asm)): DEF SEG END SUB '======================================== = ' Determines whether Windows is active and if so which version. '=============================================================== FUNCTION WindowsActive% DIM Asm AS STRING * 13 MID$(Asm, 1, 5) = CHR$(184) + MKI$(5632) + CHR$(205) + CHR$(47) MID$(Asm, 6, 5) = CHR$(104) + MKI$(VARSEG(AX)) + CHR$(31) + CHR$(163) MID$(Asm, 11, 3) = MKI$(VARPTR(AX)) + CHR$(203) DEF SEG = VARSEG(Asm): CALL ABSOLUTE(VARPTR(Asm)): DEF SEG IF (AX AND &HFF <> 0) AND (AX AND &HFF <> &H80) AND (AX <> &H1600) THEN WindowsActive% = ((AX AND &HFF) * 100) + AX \ 256 END IF END FUNCTION