I am using windows vista home premium
void open_drive(char * BUF)
{
//BUF value is \\\\.\\G:
void* ptr;
char* buffer = (char*)malloc (bytesPerSec);
DWORD bytesread;
hDevice = CreateFile(BUF,GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,NULL, OPEN_EXISTING, 0, NULL);
if (hDevice == INVALID_HANDLE_VALUE)
{
printf("This is not working :-(");
printf("\n\n%s\n",BUF);
getchar();
exit(0);
}
SetFilePointer (hDevice, 0, NULL, FILE_BEGIN);
if (!ReadFile (hDevice, buffer, bytesPerSec, &bytesread, NULL) )
exit(0);
ptr=&buffer[11];
bytesPerSec=*((short *)ptr);
secPerClus=buffer[13];
ptr=&buffer[14];
reservedSecCount=*((short *)ptr);
numFats=buffer[16];
mediaType=buffer[21];
ptr=&buffer[32];
totSec=*((int *)ptr);
ptr=&buffer[36];
fatSize=*((int *)ptr);
ptr=&buffer[44];
rootClus=*((int *)ptr);
//All values have been verified by printing their outputs...
// printf("%hd %d %hd %d %x %d %d %d",bytesPerSec,secPerClus,reservedSecCount,numFats,mediaType,totSec,fatSize,rootClus);
firstDataSector=reservedSecCount+(numFats*fatSize)+rootDirSectors;
dataSec=totSec - (reservedSecCount + (numFats*fatSize)) + rootDirSectors;
countOfClus=dataSec/secPerClus;
if(countOfClus<LIMIT_FAT32)
exit(0);
http://www.cplusplus.com/forum/windows/21731/#
}