[C] 安装设备驱动程序到BGI设备驱动程序表中 →→→→→进入此内容的聊天室

来自 , 2020-04-27, 写在 C, 查看 109 次.
URL http://www.code666.cn/view/38651c44
  1. #include <graphics.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <conio.h>
  5.  
  6. /* function prototypes */
  7. int huge detectEGA(void);
  8. void checkerrors(void);
  9.  
  10. int main(void)
  11. {
  12.    int gdriver, gmode;
  13.  
  14.    /* install a user written device driver */
  15.    gdriver = installuserdriver("EGA", detectEGA);
  16.  
  17.    /* must force use of detection routine */
  18.    gdriver = DETECT;
  19.  
  20.    /* check for any installation errors */
  21.    checkerrors();
  22.  
  23.    /* initialize graphics and local variables */
  24.    initgraph(&gdriver, &gmode, "");
  25.  
  26.    /* check for any initialization errors */
  27.    checkerrors();
  28.  
  29.    /* draw a line */
  30.    line(0, 0, getmaxx(), getmaxy());
  31.  
  32.    /* clean up */
  33.    getch();
  34.    closegraph();
  35.    return 0;
  36. }
  37.  
  38. /* detects EGA or VGA cards */
  39. int huge detectEGA(void)
  40. {
  41.    int driver, mode, sugmode = 0;
  42.  
  43.    detectgraph(&driver, &mode);
  44.    if ((driver == EGA) || (driver == VGA))
  45.       /* return suggested video mode number */
  46.       return sugmode;
  47.    else
  48.       /* return an error code */
  49.       return grError;
  50. }
  51.  
  52. /* check for and report any graphics errors */
  53. void checkerrors(void)
  54. {
  55.    int errorcode;
  56.  
  57.    /* read result of last graphics operation */
  58.    errorcode = graphresult();
  59.    if (errorcode != grOk)
  60.    {
  61.       printf("Graphics error: %s\n", grapherrormsg(errorcode));
  62.       printf("Press any key to halt:");
  63.       getch();
  64.       exit(1);
  65.    }
  66. }

回复 "安装设备驱动程序到BGI设备驱动程序表中"

这儿你可以回复上面这条便签

captcha