02-27-2003, 10:57 PM
How do i check if windows is running (95 and newer)
ell Free To Fly
Fell Free To Help Me
Fell Free To Help Me
Windows
|
02-27-2003, 10:57 PM
How do i check if windows is running (95 and newer)
ell Free To Fly
Fell Free To Help Me
02-27-2003, 11:25 PM
'
' This function can be used to determine if QB/Qbasic is being used ' within Windows (or from a DOS window under Windows). It returns a 2- ' byte integer, only the rightmost 3 bits of which will ever be nonzero-- ' i.e., WINRUN is an integer from 0 to 7. If WINRUN = 0, Windows is not ' active in any form. If bit 0 (WINRUN AND 1) is unity, Windows 3.1 is ' running in normal mode. If bit 1 ((WINRUN AND 2)/2) is unity, Windows/ ' 386 is running in enhanced mode. If bit 2 ((WINRUN AND 4)/4) is unity, ' Win 95/98's WIN.COM is running. It may be noted that even if you're ' using Win 95/98, your computer/OS will still act as if the previous ' versions of Windows are running as far as the interrupt calls made by ' this routine are concerned. ' ' To express the interpretation of the different nonzero values of WINRUN ' in English: ' ' WINRUN = 1 means that Windows 3.1 is running in normal mode, not in ' 386 enhanced mode, and further, Win 95/98 was not detected; ' ' WINRUN = 2 means that it is running in 386 enhanced mode, not normal ' mode, and further, Win 95/98 was not detected; ' ' WINRUN = 3 means that both Windows 3.1 in normal mode and 386 enhanced ' mode was detected, but Win 95/98 still wasn't; ' ' WINRUN = 4 means that Win 95/98 was detected but the previous versions ' weren't; ' ' WINRUN = 5 means that Win 95/98 and Windows 3.1 in normal mode were ' detected, but Windows/386 enhanced mode wasn't; ' ' WINRUN = 6 means that Win 95/98 and Windows/386 enhanced mode were ' detected, but Windows 3.1 normal mode wasn't; ' ' and ' ' WINRUN = 7 means that all three "versions/implementations" of Windows ' appear to be active in some form or other. ' ' A special note regarding WINRUN = 4: this appears to be just an ' indication that you've completely quit Win 95/98 to DOS. (Some ' computers return WINRUN = 0 in this situation; others return 4.) Since ' the other implementations of Windows appear not to be present and since ' most DOS programs seem to work fine in this situation (even though ' Windows may be running in some sense or other in the "background"), you ' can probably take WINRUN = 4 as an indication that Windows is not active ' for all, or at least most, intents and purposes. ' ' Your MAIN routine must incorporate a DECLARE statement in order to use ' this function: ' ' DECLARE FUNCTION WINRUN%() ' DEFINT W FUNCTION WINRUN% DIM WINCODE(1 TO 11) AS INTEGER,OS AS INTEGER,AX AS INTEGER,BX AS INTEGER DIM AL AS INTEGER,AH AS INTEGER ' ' Set up machine code to test for Windows in normal mode. ' DEF SEG=VARSEG(WINCODE(1)) OS=VARPTR(WINCODE(1)) POKE OS,&H55 'PUSH BP POKE OS+1,&H89 : POKE OS+2,&HE5 'MOV BP,SP POKE OS+3,&HB8 : POKE OS+4,&HA : POKE OS+5,&H16 'MOV AX,160A POKE OS+6,&HCD : POKE OS+7,&H2F 'INT 2F POKE OS+8,&H8B : POKE OS+9,&H7E : POKE OS+10,6 'MOV DI,[BP+6] POKE OS+11,&H89 : POKE OS+12,&H1D 'MOV [DI],BX POKE OS+13,&H8B : POKE OS+14,&H7E : POKE OS+15,8 'MOV DI,[BP+8] POKE OS+16,&H89 : POKE OS+17,5 'MOV [DI],AX POKE OS+18,&H5D 'POP BP POKE OS+19,&HCA : POKE OS+20,4 : POKE OS+21,0 'RETF 4 ' ' Call machine code to get AX and BX. ' CALL ABSOLUTE(AX,BX,OS) ' ' If AX isn't zero, function isn't supported--Windows isn't running in ' normal mode. If it is zero, function is supported and Windows is most ' likely running. BX > 0 indicates presence of normal mode. ' ' Set initial value for WINTEMP. (It will be aliased with WINRUN later.) ' WINTEMP=0 IF AX=0 THEN IF BX>0 THEN WINTEMP=WINTEMP OR 1% END IF ' ' Alter machine code to test for Windows/386 in enhanced mode. ' POKE OS+4,0 'for MOV AX,1600 ' ' Call machine code to get AX. (BX isn't used.) ' CALL ABSOLUTE(AX,BX,OS) ' ' AL being anything but zero or 80h indicates presence of Windows/386 ' enhanced mode. ' AL = AX AND &HFF IF AL<>0 AND AL<>&H80 THEN WINTEMP=WINTEMP OR 2% ' ' Alter machine code to test for presence of Win 95/98's WIN.COM. ' POKE OS+4,&H21 : POKE OS+5,&H4B 'For MOV AX,4B21 ' ' Call machine code to get AX. (BX isn't used here either.) ' CALL ABSOLUTE(AX,BX,OS) ' ' AH = 0 means that Win 95/98's WIN.COM is running. ' AH=(AX AND &HFF00)/256 : AH=(AH+256) MOD 256 IF AH=0 THEN WINTEMP=WINTEMP OR 4% DEF SEG ' ' Define WINRUN function value and get out of here. ' WINRUN=WINTEMP END FUNCTION DEFSNG W
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.) I liked spam better when it was something that came in a can. Windows should be defenestrated. |
« Next Oldest | Next Newest »
|