HARDDISK.CPP
资源名称:C++100.rar [点击查看]
上传用户:wszmarenbt
上传日期:2013-04-26
资源大小:2552k
文件大小:2k
源码类别:
Windows编程
开发平台:
Visual C++
- //THE PROGRAM IS TO DISPLAY YOUR HARDDISK'S MESSAGE
- //FILE HARDDISK.CPP
- #include <dos.h>
- #include <stdio.h>
- #include <conio.h>
- #include <ctype.h>
- #include <string.h>
- #include <process.h>
- int main(void)
- {
- struct dfree DISKMESSAGE;
- long DISK_SECTOR,DISK_CLUSTER,DISK_TOTAL,DISK_AVAIL;
- int DISKNUM;
- char DISK;
- clrscr();
- printf("n ********** WELCOME TO USE THIS SYSTEM **********n");
- printf("n ----- IT HELPS YOU KONW YOUR HARDDISK -----nn");
- do
- {
- printf("nINPUT YOUR DRIVER(A B C D E F... ...):");
- scanf("%c",&DISK);
- }while((DISK<'A')||((DISK>'Z')&&(DISK<'a'))||DISK>'z');
- if((DISK>'A')&&(DISK<'Z'))
- DISKNUM=DISK-'A'+1;
- if((DISK>'a')&&(DISK<'z'))
- DISKNUM=DISK-'a'+1;
- getdfree(DISKNUM,&DISKMESSAGE);
- if (DISKMESSAGE.df_sclus==(unsigned)-1)
- {
- printf("***** ERROR : CAN NOT GET INFORMATION FROM YOUR DISK %c:n"
- ,DISK);
- exit(1);
- }
- DISK_SECTOR=DISKMESSAGE.df_bsec;
- DISK_CLUSTER=DISKMESSAGE.df_sclus*DISK_SECTOR;
- DISK_AVAIL=DISKMESSAGE.df_avail*DISK_CLUSTER;
- DISK_TOTAL=DISKMESSAGE.df_total*DISK_CLUSTER;
- if (DISKNUM!=0)
- printf("***** HARDDISK INFORMATION %c :n",'A'+DISKNUM-1);
- else
- printf("***** HARDDISK INFORMATION (DEFAULT) : AS FOLLOWINGn");
- printf("n----- TOTAL HARDDIRSK SPACE = %ld BYTESn",DISK_TOTAL);
- printf("n***** AVAILABEL SPACE = %ld BYTESn",DISK_AVAIL);
- printf("n----- BYTES (EVERY SECTOR) = %ld BYTESn",DISK_SECTOR);
- printf("n***** BYTES (EVERY CLUSTER) = %ld BYTESn",DISK_CLUSTER);
- printf("nnn *********** Thank you! ***********n");
- printf("n ----------- <2001.01.01> -----------n");
- getch();
- return 0;
- }