|
Turbo C 2.0、Borland C++库函数及用例(40) return 0; } 函数名: getdfree 功 能: 取磁盘自由空间 用 法: void getdfree(int drive, struct dfree *dfreep); 程序例:#include <stdio.h> #include <stdlib.h> #include <dir.h> #include <dos.h>int main(void) { struct dfree free; long avail; int drive; drive = getdisk(); getdfree(drive+1, &free); if (free.df_sclus == 0xFFFF) { printf("Error in getdfree() call\n"); exit(1); } avail = (long) free.df_avail * (long) free.df_bsec * (long) free.df_sclus; printf("Drive %c: has %ld bytes \ available\n", 'A' + drive, avail); return 0; } 函数名: getdisk 功 能: 取当前磁盘驱动器号 用 法: int getdisk(void); 程序例:#include <stdio.h> #include <dir.h>int main(void) { int disk; disk = getdisk() + 'A'; printf("The current drive is: %c\n", disk); return 0; } 函数名: getdrivername 功 能: 返回指向包含当前图形驱动程序名字的字符串指针 用 法: char *getdrivename(void); 程序例:#include <graphics.h> #include <stdlib.h> #include <stdio.h> #include <conio.h>int main(void) { /* request auto detection */ int gdriver = DETECT, gmode, errorcode;/* stores the device driver name */ char *drivername;/* initialize graphics and local variables */ initgraph(&gdriver, &gmode, "");/* read result of initialization */ errorcode = graphresult(); /* an error occurred */ if (errorcode != grOk) { printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); /* terminate with an error code */ exit(1); } setcolor(getmaxcolor());/* get name of the device driver in use */ drivername = getdrivername();/* for centering text on the screen */ settextjustify(CENTER_TEXT, CENTER_TEXT);/* output the name of the driver */ outtextxy(getmaxx() / 2, getmaxy() / 2, drivername);/* clean up */ getch(); closegraph(); return 0; } 函数名: getdta 功 能: 取磁盘传输地址 用 法: char far *getdta(void); 程序例:#include <dos.h>
|