函数名: detectgraph 
 功  能: 通过检测硬件确定图形驱动程序和模式 
 用  法: #include <graphics.h> 
         void far detectgraph(int far *graphdriver, int far *graphmode); 
 程序例: 
#include <graphics.h> 
 #include <stdlib.h> 
 #include <stdio.h> 
 #include <conio.h> 
/* 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) 
 { 
    /* returns detected hardware info. */ 
    int gdriver, gmode, errorcode; 
  /* detect 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:"); 
       getch(); 
       exit(1); /* terminate with an error 
     code */ 
    } 
   /* display the information detected */ 
    clrscr(); 
    printf("You have %s video display \ 
    card.\n", dname[gdriver]); 
    printf("Press any key to halt:"); 
    getch(); 
    return 0; 
 }