Microsoft Windows CE 3.0  

DeviceIoControl

Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

This function sends a control code directly to a specified device driver, causing the corresponding device to perform the specified operation.

BOOL DeviceIoControl( HANDLE
hDevice, 
DWORD
dwIoControlCode, 
LPVOID
lpInBuffer, 
DWORD
nInBufferSize, 
LPVOID
lpOutBuffer, 
DWORD
nOutBufferSize, 
LPDWORD
lpBytesReturned, 
LPOVERLAPPED
lpOverlapped
);

Parameters

hDevice
[in] Handle to the device that is to perform the operation. Call the CreateFilefunction to obtain a device handle.
dwIoControlCode
[in] Specifies the control code for the operation. This value identifies the specific operation to be performed and the type of device on which the operation is to be performed. No specific values are defined for the dwIoControlCodeparameter. However, the writer of a custom device driver can define IOCTL_XXXXcontrol codes, per the CTL_CODEmacro. These control codes can then be advertised, and an application can use these control codes with DeviceIoControlto perform the driver-specific functions.
lpInBuffer
[in] Long pointer to a buffer that contains the data required to perform the operation.

This parameter can be NULL if the dwIoControlCodeparameter specifies an operation that does not require input data.

nInBufferSize
[in] Size, in bytes, of the buffer pointed to by lpInBuffer.
lpOutBuffer
[out] Long pointer to a buffer that receives the operation's output data.

This parameter can be NULL if the dwIoControlCodeparameter specifies an operation that does not produce output data.

nOutBufferSize
[in] Size, in bytes, of the buffer pointed to by lpOutBuffer.
lpBytesReturned
[out] Long pointer to a variable that receives the size, in bytes, of the data stored into the buffer pointed to by lpOutBuffer.

The lpBytesReturnedparameter cannot be NULL. Even when an operation produces no output data, and lpOutBuffercan be NULL, the DeviceIoControlfunction makes use of the variable pointed to by lpBytesReturned. After such an operation, the value of the variable is without meaning.

lpOverlapped
[in] Ignored; set to NULL.

Return Values

Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.

Remarks

When passed parameters such as DISK_IOCTL_GETINFO, the DeviceIoControlfunction does not change the dwBytesReturnedparameter. This is because the IOCTL_GETINFO command interface returns the information to the input buffer specified with the lpOutBufferparameter. DeviceIoControlsets dwBytesReturnedonly when the control code writes into the output buffer. Many other DISK_IOCTL_GET* command codes return this information in the input buffer, as well.

Windows CE will add zeros to a filename that contains less than 4 hex digits. For example, Windows CE would rename the NT file foo34.tmp as foo0034.tmp.

Requirements

Runs On Versions Defined in Include Link to
Windows CE OS 1.0 and later Winbase.h   Coredll.lib, Fsmain.lib
Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

See Also

CreateEvent, CreateFile, GetLastError