Microsoft KB Archive/64875

= C's _getvideoconfig Returns Incorrect Mode If Set from Basic =

Article ID: 64875

Article Last Modified on 11/21/2006

-

APPLIES TO


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

-



This article was previously published under Q64875



SUMMARY
The C graphics function _getvideoconfig will not correctly return the current video mode set by a Basic program. To work around this problem, the BIOS interrupt 10 (hex) function 0F (hex) can be used in place of the _getvideoconfig function. This is shown in the sample programs below.

This information applies to QuickBasic versions 4.00, 4.00b, and 4.50; to Microsoft Basic Compiler versions 6.00 and 6.00b; and to Microsoft Basic Professional Development System (PDS) versions 7.00 and 7.10 for MS-DOS and MS OS/2.



MORE INFORMATION
The following Basic program, TEST.BAS, sets the video to screen mode 9 (EGA) and then calls a C function to return the current graphics mode: DECLARE FUNCTION CProc% CDECL SCREEN 9 CLS PRINT &quot;Video mode: &quot;; CProc% while inkey$=&quot;&quot; : wend END The following C program, CVID.C, uses the C graphics function _getvideoconfig, which returns an incorrect value when the video mode has been set by Basic.
 * 1) include 

int CProc(void) { struct videoconfig vc; _getvideoconfig(&vc); return(vc.mode); } Compile and link as follows: BC TEST.BAS ; CL /c /AL CVID.C ; LINK /NOE TEST CVID ; Compile and link as follows: BC TEST.BAS ; CL /c /AL CVID.C ; LINK /NOE TEST CVID ; Normally, the returned video mode will be 3, which is incorrect. The following C routine replaces CVID.C. When this is compiled and linked to TEST.BAS, the correct video mode, 16, is returned.
 * 1) include 

int CProc(void) { union REGS inregs, outregs; inregs.h.ah = 0xF; int86(0x10, &inregs, &outregs); return(outregs.h.al); }

Additional query words: QuickBas BasicCom

Keywords: KB64875

-

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

© Microsoft Corporation. All rights reserved.