Preliminary User Guide, Rev. 2 | USS-720 |
February 1999 | USB Device Driver |
| |
3 I/O File Functions (continued)
3.4 DeviceIoControl
The DeviceIoControl I/O file function sends a control code to a device instance and returns TRUE if the function is successful and FALSE if it fails. Details regarding the syntax, parameters, return values, and error codes are listed below.
3.4.1 Syntax | |
BOOL | |
DeviceIoControl( | |
HANDLE | hDev, |
DWORD | dwIoControlCode, |
LPVOID | lpInBuffer, |
DWORD | nInBufferSize, |
LPVOID | lpOutBuffer, |
DWORD | nOutBufferSize, |
LPDWORD | lpBytesReturned, |
LPOVERLAPPED | lpOverlapped |
); | |
3.4.2 Parameters
Input:
hDev—Handle returned from a successful CreateFile.
dwIoControlCode—Specifies the control code for the operation. See Section 4 of this document for a list of valid I/O control codes and more detailed information on each control code.
lpInBuffer—Pointer to a buffer that contains the data required to perform the operation. This parameter can be NULL if the dwIoControlCode parameter specifies an operation that does not require input data. The usage of lpIn- Buffer is dependent on the dwIoControlCode parameter.
nInBufferSize—Specifies the size (in bytes) of the buffer pointed to by lpInBuffer. The usage of nInBufferSize is dependent on dwIoControlCode parameter.
lpOverlapped—Pointer to OVERLAPPED structure. This is an optional parameter that can be “NULL” if overlapping I/O is not required.
Output:
lpOutBufferSize—Pointer to a buffer that receives the operation’s output data. This parameter can be NULL if the dwIoControlCode parameter specifies an operation that does not require output data. The usage of lpOutBufferSize is dependent on dwIoControlCode parameter.
nOutBufferSize—Specifies the size (in bytes) of the buffer pointed to by lpOutBuffer. The usage of nOutBufferSize is dependent on dwIoControlCode parameter.
lpBytesReturned—Pointer to a variable that receives the size (in bytes) of data stored into the output buffer pointed to by lpOutBuffer. The usage of lpBytesReturned is dependent on dwIoControlCode parameter.
3.4.3 Return Values
If the function succeeds, the return value is TRUE (1).
If the function fails, the return value is FALSE (0). To get extended error information, call GetLastError.
3.4.4 Notes
See the Win32 SDK documentation for complete definitions.