#include <windows.h>
#include <windowsx.h>
#include <string.h>
#include <iostream.h>
HANDLE hFile;
HANDLE hFileNew;
DWORD d;
double tmp;
char c;
int main()
{
hFile=CreateFile("1.txt",GENERIC_READ,FILE_SHARE_READ,NULL,
OPEN_EXISTING,FILE_ATTRIBUTE_READONLY,NULL);
DWORD ff=GetFileSize(hFile,NULL);
char buf[ff];
for(int i=0;i<ff;i++)
{
ReadFile(hFile,&c,1,&d,NULL);
buf[i]=c;
cout <<c;
if(i!=0 && i%2000==0) getchar();
}
hFileNew=CreateFile("copy.txt",GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,
CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
WriteFile(hFileNew,buf,strlen(buf),&d,NULL);
DWORD dwSectorsPerClusters;
DWORD dwBytesPerSectors;
DWORD dwNumberOfFreeClusters;
DWORD dwTotalNumberOfClusters;
GetDiskFreeSpace("C:\\",&dwSectorsPerClusters,
&dwBytesPerSectors,&dwNumberOfFreeClusters,
&dwTotalNumberOfClusters);
//cout << "\n\n\ndwSectorsPerClusters=" << dwSectorsPerClusters <<"\n";
//cout << "dwBytesPerSectors=" << dwBytesPerSectors <<"\n";
//cout << "dwNumberOfFreeClusters=" << dwNumberOfFreeClusters <<"\n";
//cout << "dwTotalNumberOfClusters=" << dwTotalNumberOfClusters <<"\n";
tmp = dwSectorsPerClusters*dwNumberOfFreeClusters;
tmp = tmp/1024;
tmp = tmp/1024*dwBytesPerSectors;
cout << "\nFree space = " <<tmp << " mb";
return 0;
}