Borland C++ reference

detectgraph

raw OCR

Determines graphics driver and graphics mode to use by checking the hardware.

Defined in header <graphics.h>

Syntax

#include <graphics.h>
void far detectgraph(int far *graphdriver, intfar *graphmode);

Portability

DOSUNIXWindowsANSI CC++ only
■

Remarks

detectgraph detects your system's graphics adapter and chooses the mode that provides the highest resolution for that adapter. If no graphics hard-ware is detected, *graphdriver is set to grNotDetected (-2), and graphresult returns grNotDetected (-2).

*graphdriver is an integer that specifies the graphics driver to be used. You can give it a value using a constant of the graphics_drivers enumeration type, defined in graphics.h and listed in the following table.

Table 2.1 detectgraph

graph ics_ drivers

constants

constantNumeric value
DETECT0 (requests autodetection)
CGA1
MCGA2
EGA3
EGA644
EGAMONO5
IBM85146
HERCMONO7
ATT4008
VGA9
PC327010

*graphmode is an integer that specifies the initial graphics mode (unless *graphdriver equals DETECT; in which case, *graphmode is set to the highest resolution available for the detected driver). You can give *graphmode a value using a constant of the graphics jnodes enumeration type, defined in graphics.h and listed in the following table.

Table 2.2 Graphics drivers

GraphicsColumn

information

drivergraphics_modesValueX rowPalettePages
CGACGACO0320 X 200CO
CGACl1320 X 200CI
CGAC22320 X 200C2
CGAC33320x200C3
CGAHI4640 X 2002 color
MCGAMCGACO0320 X 200CO
MCGACl1320 X 200CI
MCGAC22320x200C2
MCGAC33320 X 200C3
MCGAMED4640 X 2002 color
MCGAHI5640 X 4802 color
EGAEGALO0640 X 20016 color4
EGAHI1640 X 35016 color2
EGA64EGA64LO0640 X 20016 color1
EGA64HI1640 X 3504 color1
EGA-MONOEGAMONOHI3640 X 3502 color
EGAMONOHI3640 X 3502 color2**
HERCHERCMONOHI0720 X 3482 color2
ATT400ATT400C00320 X 200CO1
ATT400C11320 X 200CI1
ATT400C22320 X 200C21
ATT400C33320 X 200C31
ATT400MED4640 X 2002 color1
ATT400HI5640 X 4002 color1
VGAVGALO0640 X 20016 color2
VGAMED1640 X 35016 color2
VGAHI2640 X 48016 color1
PC3270PC3270HI0720 X 3502 color1
IBM8514IBM8514HI0640 X 480256 color
IBM8514LO01024 X 768256 color

* 64K on EGAMONO card ** 256K on EGAMONO card Note: The main reason to call detectgraph directly is to override the

graphics mode that detectgraph recommendsto initgraph.

Return value

None.

See also

Example

#include <graphics.h>
#include <stdlib.h>
itinclude <stdio.h>
#include <conio.h>
/* the names of the various  cards supported */
char *dname[] =  { "requests detection",
                   "a CGA",
                   "an MCGA",
                   "an EGA",
                   "a 64K EGA",
                   "a monochrome EGA",
                   "an IBM 8514",
                   "a Hercules monochrome",
                   "an AT&T 6300 PC",
                   "a VGA",
                   "an IBM 3270 PC"

int main (void)
{
   /* used to return detected  hardware info. */
   int gdriver, gmode, errorcode;

   /* detect the graphics hardware  available */
   detectgraph (&gdriver, &gmode);

   /* read result of detectgraph  call */
   errorcode = graphresult ();
   if (errorcode  != grOk) {  /* an error occurred */
      printf("Graphics error:  %s\n", grapherrormsg(errorcode)
      printf ("Press any key to halt:");
      getchO ;
      exit(l);                /* terminate with an error code */

   /* display the information  detected */
   clrscr 0;
   printf("You have %s video display  card.\n", dname[gdriver]);
   printf("Press any key to halt:");
   getchO ;
   return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.