SetFileBandwidthReservation function (Windows)

Switch View :
ScriptFree
SetFileBandwidthReservation function

Applies to: desktop apps only

Requests that bandwidth for the specified file stream be reserved. The reservation is specified as a number of bytes in a period of milliseconds for I/O requests on the specified file handle.

Syntax

BOOL WINAPI SetFileBandwidthReservation(
  __in   HANDLE hFile,
  __in   DWORD nPeriodMilliseconds,
  __in   DWORD nBytesPerPeriod,
  __in   BOOL bDiscardable,
  __out  LPDWORD lpTransferSize,
  __out  LPDWORD lpNumOutstandingRequests
);

Parameters

hFile [in]

A handle to the file.

nPeriodMilliseconds [in]

The period of the reservation, in milliseconds. The period is the time from which the I/O is issued to the kernel until the time the I/O should be completed. The minimum supported value for the file stream can be determined by looking at the value returned through the lpPeriodMilliseconds parameter to the GetFileBandwidthReservation function, on a handle that has not had a bandwidth reservation set.

nBytesPerPeriod [in]

The bandwidth to reserve, in bytes per period. The maximum supported value for the file stream can be determined by looking at the value returned through the lpBytesPerPeriod parameter to the GetFileBandwidthReservation function, on a handle that has not had a bandwidth reservation set.

bDiscardable [in]

Indicates whether I/O should be completed with an error if a driver is unable to satisfy an I/O operation before the period expires. If one of the drivers for the specified file stream does not support this functionality, this function may return success and ignore the flag. To verify whether the setting will be honored, call the GetFileBandwidthReservation function using the same hFile handle and examine the *pDiscardable return value.

lpTransferSize [out]

A pointer to a variable that receives the minimum size of any individual I/O request that may be issued by the application. All I/O requests should be multiples of TransferSize.

lpNumOutstandingRequests [out]

A pointer to a variable that receives the number of TransferSize chunks the application should allow to be outstanding with the operating system. This allows the storage stack to keep the device busy and allows maximum throughput.

Return value

Returns nonzero if successful or zero otherwise.

A reservation can fail if there is not enough bandwidth available on the volume because of existing reservations; in this case ERROR_NO_SYSTEM_RESOURCES is returned.

To get extended error information, call GetLastError.

Remarks

The requested bandwidth reservation must be greater than or equal to one packet per period. The minimum period, in milliseconds, maximum bytes per period, and minimum transfer size, in bytes, for a specific volume are returned through the lpPeriodMilliseconds, lpBytesPerPeriod, and lpTransferSize parameters to GetFileBandwidthReservation on a handle that has not been used in a call to SetFileBandwidthReservation. In other words:

1 ≤ (nBytesPerPeriod)×(*lpPeriodMilliseconds)/(*lpTransferSize)/(nPeriodMilliseconds)

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2008

Header

WinBase.h (include Windows.h)

Library

Kernel32.lib

DLL

Kernel32.dll

See also

File Management Functions
GetFileBandwidthReservation

 

 

Send comments about this topic to Microsoft

Build date: 4/17/2012

Community Content

John PDF
This API fails on my Windows7 and Windows Server 2008 machines.
So, if this API returns false, and GetLastError returns 1, what does this mean? What needs to be done to provide support for it? (updated drivers?) btw, I get the same result calling GetFileBandwidthReservation.

Stratcat
It's fine - as long as you know how to program
Calm down OP.  Your rant really just shows how skilled you are (or 'are not' as the case may be) developing software.

1 ≤ (nBytesPerPeriod)×(*lpPeriodMilliseconds)/(*lpTransferSize)/(nPeriodMilliseconds)

Look at the 'lp' before PeriodMilliseconds and TransferSize.  To everyone else they know it's a pointer so yes - it is a dereference.  Yes, walk the line from left to right - that's how the multiplication/division works.  The documentation is not great but it should be good enough for you to make sense of it.

1 ≤ ((nBytesPerPeriod*PeriodMilliseconds)/TransferSize)/nPeriodMilliseconds


Ventsislav Alexandriyski
Sofisticated and unclear
It is not clear to me how to use this function at all. Explanation is excessively complicated and stupid as formula used to summarize it.
Who teach you on mathematics?
1 ≤ (nBytesPerPeriod)×(*lpPeriodMilliseconds)/(*lpTransferSize)/(nPeriodMilliseconds)
You cannot write it in this way.
You must specify priority on operations using brackets.
I want to read simple and clear explanations, and not to think on question "to be or not to be".
Explanation is complicated and unclear and on top of that is this formula:
1 ≤ (nBytesPerPeriod)×(*lpPeriodMilliseconds)/(*lpTransferSize)/(nPeriodMilliseconds)
What I must do first to divide or to multiply? Both have same priority.
And what means * here? Dereference, that means value itself? Not everyone programs on C.
Also it is clear that are used values but not pointers
I cannot imagine how stupid man can use dereferenced pointers in formula. Are you OK at all?
I do not know how you find people that works for MS, but it is sure it is doing with competition, because such stupid people cannot be found just like that.
I have sent to MS business offer few time but it is always rejected, because there have same stupid man without imagination that can reject it just for fun.
Name of your company MICROsoft clearly states your scales you can use in your projects, and must remind you that you have micro view and therefore everything you do is micro

And congratulations for this useless table called surface. Such useless garbage cannot be invented easy, so it is not big surprise that it have been developed for years,
And how many you have sell 2?....3?.....Less? Less sounds better

Ventsislav Alexandriyski
Complicated
It is not clear to me how to use this function at all. Explanation is excessively complicated and stupid as formula used to summarize it.
Who teach you on mathematics?
1 ≤ (nBytesPerPeriod)×(*lpPeriodMilliseconds)/(*lpTransferSize)/(nPeriodMilliseconds)
You cannot write it in this way.
You must specify priority on operations using brackets.
I want to read simple and clear explanations, and not to think on question "to be or not to be".

Explanation is sofisticated and unclear and on top of that is this formula:
1 ≤ (nBytesPerPeriod)×(*lpPeriodMilliseconds)/(*lpTransferSize)/(nPeriodMilliseconds)

What I must do first to divide or to multiply? Both have same priority.
And what means * here? Dereference, that means value itself? Not everyone programs on C.
Also it is clear that are used values but not pointers
I cannot imagine how stupid man can use dereferenced pointers in formula. Are you OK at all?

I do not know how you find people that works for MS, but it is sure it is doing with competition, necause such stupid people cannot be found just like that.

I have sent to MS business offer few time but it is always rejected, because there have same stupid man tiwhout imagination that can reject it just for fun.

Name of your company MICROsoft clearly states your scales you can use in your projects, and must remaind you that you have micro view and therefore everithing you do is micro