求大神C盘最后一个扇区数据读写的问题
HANDLE m_hDevice = CreateFileA(
"\\\\.\\C:",GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, NULL, NULL);
if (m_hDevice == INVALID_HANDLE_VALUE){
m_hDevice = NULL;
printf("CreateFileA error!!\n");
return -1;
}
ULARGE_INTEGER FreeAv, TotalBytes, FreeBytes;
GetDiskFreeSpaceExW(L"C:", &FreeAv, &TotalBytes, &FreeBytes);
LARGE_INTEGER liCurrentPosition;
liCurrentPosition.QuadPart = TotalBytes.QuadPart - 512; //最后
SetFilePointerEx(m_hDevice, liCurrentPosition, &liCurrentPosition, FILE_BEGIN);
DWORD DCount = 0; //计数}
char lpOutBuffer512[1024];
BOOL bResult = ReadFile(m_hDevice, lpOutBuffer512, 1024, &DCount, NULL);
for (int i = 0; i < 1024; i++)
printf("%c\t", lpOutBuffer512[i]);
CloseHandle(m_hDevice);
getchar();
return 0;
}