DeviceIoControl

DeviceIoControl sends a control code directly to a specified file system driver, causing the corresponding device to perform the specified operation.

Syntax

Copy
BOOL DeviceIoControl(
    [in]                       HANDLE hDevice,
    [in]                       DWORD IoControlCode,
    [in, optional]             LPVOID lpInBuffer,
    [in]                       DWORD nInBufferSize,
    [out, optional]            LPVOID lpOutBuffer,
    [in]                       DWORD nOutBufferSize,
    [out, optional]            LPDWORD lpBytesReturned,
    [in, out, optional]        LPOVERLAPPED lpOverlapped
);

Parameters

[in] hDevice

A handle to the device that is to perform the operation. Call GetLastError to obtain a device handle.

[in] IoControlCode

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. The following values are defined:

Value Definition

IOCTL_DISK_CHECK_VERIFY

Obsolete. Use IOCTL_STORAGE_CHECK_VERIFY.

IOCTL_DISK_EJECT_MEDIA

Obsolete. Use IOCTL_STORAGE_EJECT_MEDIA.

IOCTL_DISK_FORMAT_TRACKS

Formats a contiguous set of disk tracks.

IOCTL_DISK_GET_DRIVE_GEOMETRY

Obtains information on the physical disk's geometry.

IOCTL_DISK_GET_DRIVE_LAYOUT

Provides information about each partition on a disk.

IOCTL_DISK_GET_MEDIA_TYPES

Obsolete. Use IOCTL_STORAGE_GET_MEDIA_TYPES.

IOCTL_DISK_GET_PARTITION_INFO

Obtains disk partition information.

IOCTL_DISK_LOAD_MEDIA

Obsolete. Use IOCTL_STORAGE_LOAD_MEDIA.

IOCTL_DISK_MEDIA_REMOVAL

Obsolete. Use IOCTL_STORAGE_MEDIA_REMOVAL.

IOCTL_DISK_PERFORMANCE

Provides disk performance information.

IOCTL_DISK_REASSIGN_BLOCKS

Maps disk blocks to spare-block pool.

IOCTL_DISK_SET_DRIVE_LAYOUT

Partitions a disk.

IOCTL_DISK_SET_PARTITION_INFO

Sets the disk partition type.

IOCTL_DISK_VERIFY

Performs logical format of a disk extent.

IOCTL_SERIAL_LSRMST_INSERT

Enables or disables placement of a line and modem status data into the data stream.

IOCTL_DISK_STORAGE_CHECK_VERIFY

Checks for change in a removable-media device.

IOCTL_DISK_STORAGE_EJECT_MEDIA

Ejects media from a SCSI device.

IOCTL_DISK_STORAGE_GET_MEDIA_TYPES

Obtains information about media support.

IOCTL_DISK_STORAGE_LOAD_MEDIA

Loads media into a device.

IOCTL_DISK_STORAGE_MEDIA_REMOVAL

Enables or disables the media eject mechanism.

For more detailed information on each control code, see its topic in the Microsoft documentation. Each topic provides details on the usage of the lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, and lpBytesReturned parameters.

[in, optional] lpInBuffer

A pointer to a buffer that contains the data required to perform the operation.

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

[in] nInBufferSize

The size, in bytes, of the buffer pointed to by lpInBuffer.

[out, optional] lpOutBuffer

A pointer to a buffer that receives the operation's output data.

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

[in] nOutBufferSize

The size, in bytes, of the buffer pointed to by lpOutBuffer.

[out, optional] lpBytesReturned

A pointer to a variable that receives the size, in bytes, of the data stored into the buffer pointed to by lpOutBuffer.

[in, out, optional] lpOverlapped

Ignored. This parameter should be set to NULL.

Return Value

If the function succeeds, it returns TRUE. If the function fails, it returns FALSE. Call GetLastError to get extended error information.

Requirements

Minimum supported version Header Library

wRTOS 1.0 SDK

windows.h

wRTOS_rtss.lib

See Also: