#include <iostream.h>
#include <dos.h>
#include <dir.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
//--------------------------------------------------------------------
void chkdsk ( )
{
dfree fdisk ;
int disk = getdisk() ;
getdfree( disk+1 , &fdisk ) ;
cout << endl ;
cout << "Information for Disk Drive : " ;
cout << ( ( (disk+1) == 3 ) > "C:" :
( (disk+1) == 4 ) > "D:" :
( (disk+1) == 5 ) > "E:" :
"" );
int x, y ;
cout << endl ;
cout << endl ;
x = wherex() , y = wherey() ;
gotoxy ( x+10 , y ) ;
cout <<"Total Clusters .......... : " ;
cout << (long)fdisk.df_total << endl; /* Total clusters */
cout << endl ;
x = wherex() , y = wherey() ;
gotoxy ( x+10 , y ) ;
cout <<"Sector Per Cluster ...... : " ;
cout << (long)fdisk.df_sclus << endl; /* Sectors per cluster */
cout << endl ;
x = wherex() , y = wherey() ;
gotoxy ( x+10 , y ) ;
cout <<"Bytes Per Sector ........ : " ;
cout << (long)fdisk.df_bsec << endl; /* Bytes per sector */
cout << endl ;
x = wherex() , y = wherey() ;
gotoxy ( x+10 , y ) ;
cout <<"Total Disk Size ......... : " ;
cout << (long)fdisk.df_total*(long)fdisk.df_sclus*(long)fdisk.df_bsec ;
cout << " Bytes Available";
cout << endl ;
cout << endl ;
cout << endl ;
x = wherex() , y = wherey() ;
gotoxy ( x+10 , y ) ;
cout <<"Total Clusters Free ..... : " ;
cout << (long)fdisk.df_avail << endl; /* Available clusters */
cout << endl ;
x = wherex() , y = wherey() ;
gotoxy ( x+10 , y ) ;
cout <<"Total Free Space ........ : " ;
cout << (long)fdisk.df_avail*(long)fdisk.df_sclus*(long)fdisk.df_bsec ;
cout << " Bytes Available";
}
//***********************************
void chkdsk ( char *arg )
{
char driveletter[1];
strncpy ( driveletter , arg , 1 ) ;
driveletter[1] = '\0' ;
int disk = 0 ;
if ( strcmpi ( driveletter , "C" ) == 0 )
{
disk = 3 ;
}
else
if ( strcmpi ( driveletter , "D" ) == 0 )
{
disk = 4 ;
}
else
{
cout << driveletter ;
exit(0);
}
dfree fdisk ;
getdfree( disk , &fdisk ) ;
cout << endl ;
cout << "Information for Disk Drive : " ;
cout << ( ( (disk) == 3 ) > "C:" :
( (disk) == 4 ) > "D:" :
( (disk) == 5 ) > "E:" :
"" );
int x, y ;
cout << endl ;
cout << endl ;
x = wherex() , y = wherey() ;
gotoxy ( x+10 , y ) ;
cout <<"Total Clusters .......... : " ;
cout << (long)fdisk.df_total << endl; /* Total clusters */
cout << endl ;
x = wherex() , y = wherey() ;
gotoxy ( x+10 , y ) ;
cout <<"Sector Per Cluster ...... : " ;
cout << (long)fdisk.df_sclus << endl; /* Sectors per cluster */
cout << endl ;
x = wherex() , y = wherey() ;
gotoxy ( x+10 , y ) ;
cout <<"Bytes Per Sector ........ : " ;
cout << (long)fdisk.df_bsec << endl; /* Bytes per sector */
cout << endl ;
x = wherex() , y = wherey() ;
gotoxy ( x+10 , y ) ;
cout <<"Total Disk Size ......... : " ;
cout << (long)fdisk.df_total*(long)fdisk.df_sclus*(long)fdisk.df_bsec ;
cout << " Bytes Available";
cout << endl ;
cout << endl ;
cout << endl ;
x = wherex() , y = wherey() ;
gotoxy ( x+10 , y ) ;
cout <<"Total Clusters Free ..... : " ;
cout << (long)fdisk.df_avail << endl; /* Available clusters */
cout << endl ;
x = wherex() , y = wherey() ;
gotoxy ( x+10 , y ) ;
cout <<"Total Free Space ........ : " ;
cout << (long)fdisk.df_avail*(long)fdisk.df_sclus*(long)fdisk.df_bsec ;
cout << " Bytes Available";
}
//--------------------------------------------------------------------
void main ( int argc , char *args[] )
{
if ( argc == 1 )
chkdsk ();
else
if ( argc == 2 )
chkdsk ( args[1] ) ;
else
cout << "Incorrect Synatx.";
}
Tuesday, March 10, 2009
C Program Check Disk (CHKDSK)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment