Fat32格式获取簇号不对 大神帮忙看看
GetDiskFreeSpace(Name, &SecPerCl, &BtPerSec, NULL, NULL);//该函数是获取指定磁盘的信息
*ClusterSize = SecPerCl * BtPerSec;//一个簇的字节数
hFile = CreateFile(lpFileName, FILE_READ_ATTRIBUTES,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
NULL, OPEN_EXISTING, 0, 0);
if (hFile != INVALID_HANDLE_VALUE)
{
*FileSize = GetFileSize(hFile, NULL);
OutSize = sizeof(RETRIEVAL_POINTERS_BUFFER) + (*FileSize / *ClusterSize) * sizeof(OutBuf->Extents);
OutBuf = (RETRIEVAL_POINTERS_BUFFER *)malloc(OutSize);
InBuf.StartingVcn.QuadPart = 0;
if (DeviceIoControl(hFile, FSCTL_GET_RETRIEVAL_POINTERS, &InBuf,
sizeof(InBuf), OutBuf, OutSize, &Bytes, NULL))
{
*ClCount = (*FileSize + *ClusterSize - 1) / *ClusterSize;
Clusters = (ULONGLONG *)malloc(*ClCount * sizeof(ULONGLONG));
PrevVCN = OutBuf->StartingVcn;
for (r = 0, Cls = 0; r < OutBuf->ExtentCount; r++)
{
Lcn = OutBuf->Extents[r].Lcn;
for (CnCount = (ULONG)(OutBuf->Extents[r].NextVcn.QuadPart - PrevVCN.QuadPart);
CnCount; CnCount--, Cls++, Lcn.QuadPart++)
Clusters[Cls] = Lcn.QuadPart;//获取簇号 //获取的前几个簇总是不对
PrevVCN = OutBuf->Extents[r].NextVcn;
}
}
} Fat32? 簇号
[解决办法]
看下是否是GetDiskFreeSpace的问题