I need to implement an application that transfers data from disk. It is important that the data throughput is constant enough and not interrupted by any other disk activity.
Starting with Windows Vista, the GetFileBandwidthReservation () and SetFileBandwidthReservation () functions have been specifically introduced for this purpose. However, I cannot get this to work. I searched on the Internet, but I cannot find much information about this (and working code samples do not seem to exist on the Internet).
Code to play:
HANDLE h = ::CreateFile(L"D:\\testfile", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING | FILE_FLAG_SEQUENTIAL_SCAN, NULL); DWORD periodMilliseconds, bytesPerPeriod, transferSize, numOutstandingRequests; BOOL discardable; BOOL result = ::GetFileBandwidthReservation(h, &periodMilliseconds, &bytesPerPeriod, &discardable, &transferSize, &numOutstandingRequests); if (result == FALSE)
A call to GetFileBandwidthReservation always returns FALSE, which indicates a failure. GetLastError returns 1, which is not very useful. If I try to call * Set * FileBandwithReservation, I get the same result.
I am testing this on a PC with Windows Server 2008 SP2 (32-bit).
Does anyone have an idea of ββwhat I'm doing wrong? Any help would be greatly appreciated.
source share