Microsoft KB Archive/40548

= Using CALL INTERRUPT to Determine Current Video Mode =

Article ID: 40548

Article Last Modified on 8/16/2005

-

APPLIES TO


 * Microsoft Visual Basic for MS-DOS
 * Microsoft QuickBasic 4.0
 * Microsoft QuickBASIC 4.0b
 * Microsoft QuickBasic 4.5 for MS-DOS
 * Microsoft BASIC Compiler 6.0
 * Microsoft BASIC Compiler 6.0b
 * Microsoft BASIC Professional Development System 7.0
 * Microsoft BASIC Professional Development System 7.1

-



This article was previously published under Q40548



SUMMARY
Microsoft Visual Basic for MS-DOS cannot determine which kind of video card is installed on your machine. However, you can use the CALL INTERRUPT statement to invoke ROM BIOS video Interrupt 10h, function 0Fh (Get Video Mode) to find out which video mode the machine is currently using. From the information returned by this interrupt, you can determine whether the video card installed is a monochrome card, such as a Hercules or compatible card, or if it is a color card, such as an IBM CGA, EGA, VGA, or compatible card.

In Microsoft QuickBasic for MS-DOS, versions 2.0, 2.01, and 3.0, you can use the CALL INT86 routine instead of CALL INTERRUPT to invoke the video interrupt.



MORE INFORMATION
A Basic application may need to determine whether or not the video system in the machine it is running on is monochrome or color (that is, to decide which colors to use for its output, etc.).

The ROM BIOS Interrupt 10h, function 0Fh, will return the current video mode. If this interrupt returns a 7 in the AL register, the video card is a monochrome card and cannot support color. If it returns something other than 7, the video card can support color; however, this does NOT determine whether or not a color monitor is connected to the computer.

Also, this function can determine where video memory for text mode begins. If the function returns 7, video memory begins at the segment paragraph address of B000h; otherwise, it begins at segment B800h.

For more information, see Page 415 of &quot;Advanced MS-DOS&quot; by Ray Duncan (Microsoft Press, 1986) and Page 45 of &quot;Microsoft QuickBasic Programmer's Toolbox&quot; by John Clark Craig (Microsoft Press, 1988).

The following sample listing demonstrates the use of CALL INTERRUPT to obtain the current video mode. ' To try this example in VBDOS.EXE: ' 1. From the File menu, choose New Project. ' 2. Copy the code example to the Code window. ' 3. Press F5 to run the program. ' ' To run this program in the environment, you must invoke the ' environment with the /L switch to load the default Quick library: ' VBDOS.EXE /L for Visual Basic 1.0 for MS-DOS ' QB /L QB.QLB or QB /L QB.LIB for QuickBasic for MS-DOS ' QB /L QBX.QLB for Basic PDS for MS-DOS ' Use the following include file for Visual Basic 1.0 for MS-DOS: REM $INCLUDE: 'VBDOS.BI' ' Use the following include file for QuickBasic for MS-DOS: REM $INCLUDE: 'QB.BI' ' Use the following include file for Basic PDS for MS-DOS: REM $INCLUDE: 'QBX.BI'

FUNCTION GetVMode% STATIC

' ' Function to return the current video mode. The mode value returned ' is the same value returned from Interrupt 10h, function 0Fh -- Get ' Video Mode (7 = Monochrome card, other = color graphics card). ' DIM InRegs AS RegType, OutRegs AS RegType InRegs.ax = &HF00                   ' INT 10h, Fn. 0Fh (get vmode). CALL INTERRUPT(&H10, InRegs, OutRegs) GetVMode% = OutRegs.ax AND 255      ' AL returns the Video Mode. END FUNCTION

Additional query words: VBmsdos QuickBas BasicCom 1.00 4.00 4.00b 4.50 6.00 6.00b 7.00 7.10

Keywords: KB40548

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.