GetDiskFreeSpace()的奇怪输出

时间:2014-06-10 17:49:53

标签: c++ winapi

我认为我设置GetDiskFreeSpace()函数是正确的,但我的输出看起来不正确。

#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;

我没有收到任何错误或警告但是当我构建并运行时,我的输出看起来完全错误:

Sectors Per Cluster: 3435973836
Bytes Per Sector: 3435973836
Free Clusters: 3435973836
Total Clusters: 3435973836

我不确定为什么变量可能已经初始化了?我还为错误处理添加了一个if语句:

if (diskClust == 0){ cout << "GetDiskFreeSpace failed with error: "<<GetLastError() << endl; }

输出为GetDiskFreeSpace failed with error: 1

0 个答案:

没有答案