I think I set up the GetDiskFreeSpace() function correct but my output does not look right.
#define wszDrive L"\\\\.\\PhysicalDrive0"
DWORD dwSectPerClust,
dwBytesPerSect,
dwFreeClusters,
dwTotalClusters;
BOOL diskClust = 0;
diskClust = GetDiskFreeSpace(wszDrive,
&dwSectPerClust,
&dwBytesPerSect,
&dwFreeClusters,
&dwTotalClusters);
cout << "Sectors Per Cluster: " << dwSectPerClust << endl;
cout << "Bytes Per Sector: " << dwBytesPerSect << endl;
cout << "Free Clusters: " << dwFreeClusters << endl;
cout << "Total Clusters: " << dwTotalClusters << endl;
I don't get any errors or warnings but when I build and run this is how my output looks completely wrong:
Sectors Per Cluster: 3435973836
Bytes Per Sector: 3435973836
Free Clusters: 3435973836
Total Clusters: 3435973836
I am not sure why the variables might already be initialized? I also added an if statement for error handling:
if (diskClust == 0){ cout << "GetDiskFreeSpace failed with error: "<<GetLastError() << endl; }
With an output of GetDiskFreeSpace failed with error: 1