intmain(void)
{
intdisk;
disk=getdisk()+'A';
printf("Thecurrentdriveis:
%c\n",
disk);
return0;
}
函数名:
getdrivername
功能:
返回指向包含当前图形驱动程序名字的字符串指针
用法:
char*getdrivename(void);
程序例:
#include
#include
#include
#include
intmain(void)
{
/*requestautodetection*/
intgdriver=DETECT,gmode,errorcode;
/*storesthedevicedrivername*/
char*drivername;
/*initializegraphicsandlocalvariables*/
initgraph(&gdriver,&gmode,"");
/*readresultofinitialization*/
errorcode=graphresult();
/*anerroroccurred*/
if(errorcode!
=grOk)
{
printf("Graphicserror:
%s\n",
grapherrormsg(errorcode));
printf("Pressanykeytohalt:
");
getch();
/*terminatewithanerrorcode*/
exit
(1);
}
setcolor(getmaxcolor());
/*getnameofthedevicedriverinuse*/
drivername=getdrivername();
/*forcenteringtextonthescreen*/
settextjustify(CENTER_TEXT,CENTER_TEXT);
/*outputthenameofthedriver*/
outtextxy(getmaxx()/2,getmaxy()/2,
drivername);
/*cleanup*/
getch();
closegraph();
return0;
}
函数名:
getdta
功能:
取磁盘传输地址
用法:
charfar*getdta(void);
程序例:
#include
#include
intmain(void)
{
charfar*dta;
dta=getdta();
printf("Thecurrentdisktransfer\
addressis:
%Fp\n",dta);
return0;
}
函数名:
getenv
功能:
从环境中取字符串
用法:
char*getenv(char*envvar);
程序例:
#include
#include
intmain(void)
{
char*s;
s=getenv("COMSPEC");/*getthecomspecenvironmentparameter*/
printf("Commandprocessor:
%s\n",s);/*displaycomspecparameter*/
return0;
}
函数名:
getfat,getfatd
功能:
取文件分配表信息
用法:
voidgetfat(intdrive,structfatinfo*fatblkp);
程序例:
#include
#include
intmain(void)
{
structfatinfodiskinfo;
intflag=0;
printf("PleaseinsertdiskindriveA\n");
getchar();
getfat(1,&diskinfo);
/*getdriveinformation*/
printf("\nDriveA:
is");
switch((unsignedchar)diskinfo.fi_fatid)
{
case0xFD:
printf("360Klowdensity\n");
break;
case0xF9:
printf("1.2Meghighdensity\n");
break;
default:
printf("unformatted\n");
flag=1;
}
if(!
flag)
{
printf("sectorspercluster%5d\n",
diskinfo.fi_sclus);
printf("numberofclusters%5d\n",
diskinfo.fi_nclus);
printf("bytespersector%5d\n",
diskinfo.fi_bysec);
}
return0;
}
函数名:
getfillpattern
功能:
将用户定义的填充模式拷贝到内存中
用法:
voidfargetfillpattern(charfar*upattern);
程序例:
#include
#include
#include
#include
intmain(void)
{
/*requestautodetection*/
intgdriver=DETECT,gmode,errorcode;
intmaxx,maxy;
charpattern[8]={0x00,0x70,0x20,0x27,0x25,0x27,0x04,0x04};
/*initializegraphicsandlocalvariables*/
initgraph(&gdriver,&gmode,"");
/*readresultofinitialization*/
errorcode=graphresult();
if(errorcode!
=grOk)/*anerroroccurred*/
{
printf("Graphicserror:
%s\n",grapherrormsg(errorcode));
printf("Pressanykeytohalt:
");
getch();
exit
(1);/*terminatewithanerrorcode*/
}
maxx=getmaxx();
maxy=getmaxy();
setcolor(getmaxcolor());
/*selectauserdefinedfillpattern*/
setfillpattern(pattern,getmaxcolor());
/*fillthescreenwiththepattern*/
bar(0,0,maxx,maxy);
getch();
/*getthecurrentuserdefinedfillpattern*/
getfillpattern(pattern);
/*alterthepatternwegrabbed*/
pattern[4]-=1;
pattern[5]-=3;
pattern[6]+=3;
pattern[7]-=4;
/*selectournewpattern*/
setfillpattern(pattern,getmaxcolor());
/*fillthescreenwiththenewpattern*/
bar(0,0,maxx,maxy);
/*cleanup*/
getch();
closegraph();
return0;
}
函数名:
getfillsettings
功能:
取得有关当前填充模式和填充颜色的信息
用法:
voidfargetfillsettings(structfillsettingstypefar*fillinfo);
程序例:
#include
#include
#include
#include
/thenamesofthefillstylessupported*/
char*fname[]={"EMPTY_FILL",
"SOLID_FILL",
"LINE_FILL",
"LTSLASH_FILL",
"SLASH_FILL",
"BKSLASH_FILL",
"LTBKSLASH_FILL",
"HATCH_FILL",
"XHATCH_FILL",
"INTERLEAVE_FILL",
"WIDE_DOT_FILL",
"CLOSE_DOT_FILL",
"USER_FILL"
};
intmain(void)
{
/*requestautodetection*/
intgdriver=DETECT,gmode,errorcode;
structfillsettingstypefillinfo;
intmidx,midy;
charpatstr[40],colstr[40];
/*initializegraphicsandlocalvariables*/
initgraph(&gdriver,&gmode,"");
/*readresultofinitialization*/
errorcode=graphresult();
if(errorcode!
=grOk)/*anerroroccurred*/
{
printf("Graphicserror:
%s\n",grapherrormsg(errorcode));
printf("Pressanykeytohalt:
");
getch();
exit
(1);/*terminatewithanerrorcode*/
}
midx=getmaxx()/2;
midy=getmaxy()/2;
/*getinformationaboutcurrentfillpatternandcolor*/
getfillsettings(&fillinfo);
/*convertfillinformationintostrings*/
sprintf(patstr,"%sisthefillstyle.",fname[fillinfo.pattern]);
sprintf(colstr,"%disthefillcolor.",fillinfo.color);
/*displaytheinformation*/
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(midx,midy,patstr);
outtextxy(midx,midy+2*textheight("W"),colstr);
/*cleanup*/
getch();
closegraph();
return0;
}
函数名:
getftime
功能:
取文件日期和时间
用法:
intgetftime(inthandle,structftime*ftimep);
程序例:
#include
#include
intmain(void)
{
FILE*stream;
structftimeft;
if((stream=fopen("TEST.$$$",
"wt"))==NULL)
{
fprintf(stderr,
"Cannotopenoutputfile.\n");
return1;
}
getftime(fileno(stream),&ft);
printf("Filetime:
%u:
%u:
%u\n",
ft.ft_hour,ft.ft_min,
ft.ft_tsec*2);
printf("Filedate:
%u/%u/%u\n",
ft.ft_month,ft.ft_day,
ft.ft_year+1980);
fclose(stream);
return0;
}
函数名:
getgraphmode
功能:
返回当前图形模式
用法:
intfargetgraphmode(void);
程序例:
#include
#include
#include
#include
intmain(void)
{
/*requestautodetection*/
intgdriver=DETECT,gmode,errorcode;
intmidx,midy,mode;
charnumname[80],modename[80];
/*initializegraphicsandlocalvariables*/
initgraph(&gdriver,&gmode,"");
/*readresultofinitialization*/
errorcode=graphresult();
/*anerroroccurred*/
if(errorcode!
=grOk)
{
printf("Graphicserror:
%s\n",
grapherrormsg(errorcode));
printf("Pressanykeytohalt:
");
getch();
/*terminatewithanerrorcode*/
exit
(1);
}
midx=getmaxx()/2;
midy=getmaxy()/2;
/*getmodenumberandnamestrings*/
mode=getgraphmode();
sprintf(numname,
"%disthecurrentmodenumber.",
mode);
sprintf(modename,
"%sisthecurrentgraphicsmode",
getmodename(mode));
/*displaytheinformation*/
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(midx,midy,numname);
outtextxy(midx,midy+2*textheight("W"),
modename);
/*cleanup*/
getch();
closegraph();
return0;
}
函数名:
getftime
功能:
取文件日期和时间
用法:
intgetftime(inthandle,structftime*ftimep);
程序例:
#include
#include
intmain(void)
{
FILE*stream;
structftimeft;
if((stream=fopen("TEST.$$$",
"wt"))==NULL)
{
fprintf(stderr,
"Cannotopenoutputfile.\n");
return1;
}
getftime(fileno(stream),&ft);
printf("Filetime:
%u:
%u:
%u\n",
ft.ft_hour,ft.ft_min,
ft.ft_tsec*2);
printf("Filedate:
%u/%u/%u\n",
ft.ft_month,ft.ft_day,
ft.ft_year+1980);
fclose(stream);
return0;
}