|
Home Site Structure Programming Home Basic Home GUI & OS Home QB Knowledge Base Professor Answers Codename Surena QB Downloads Write Us
Special LinksQB DirectoryNEW Codename Surena Forums |
|
||
How to get MS-DOS version? '$INCLUDE: 'qb.bi' DIM Regs AS RegType Regs.AX = &H3306 CALL INTERRUPT(&H21, Regs, Regs) IF Regs.AX = &HFF THEN Regs.AX = &H3001 CALL INTERRUPT(&H21, Regs, Regs) PRINT LowByte(Regs.AX); "."; HighByte(Regs.AX) ELSE PRINT LowByte(Regs.BX); "."; HighByte(Regs.BX) END IF 'This function returns the high byte of an INTEGER value. FUNCTION HighByte (value AS INTEGER) DEF SEG = VARSEG(value) HighByte = PEEK(VARPTR(value)+1) DEF SEG END FUNCTION 'This function returns the low byte of an INTEGER value. FUNCTION LowByte (value AS INTEGER) LowByte = value AND &HFF END FUNCTION The function &H3306 is only supported under DOS 5 or later. So the code checks if this function fails or not. If the function fails, this code will call function &H3001 to retrieve MS-DOS version. Function &H3306 returns the major version in BL register and minor version in BH. &H3001 returns the major version number in AL and the minor version number in AH. If you want to use this code in QBASIC 1.1 that does not support INTERRUPT routine, see ht7: How to imitate CALL INTERRUPT in QBASIC 1.1? |