IOCTL_STORAGE_QUERY_PROPERTY control code
Returns the properties of a storage device or adapter. The request indicates the kind of information to retrieve, such as the inquiry data for a device or the capabilities and limitations of an adapter. IOCTL_STORAGE_QUERY_PROPERTY can also be used to determine whether the port driver supports a particular property or which fields in the property descriptor can be modified with a subsequent change-property request.
BOOL WINAPI DeviceIoControl( _In_ (HANDLE) hDevice, // handle to a partition _In_ (DWORD) IOCTL_STORAGE_QUERY_PROPERTY, // dwIoControlCode _In_ (LPVOID) lpInBuffer, // input buffer - STORAGE_PROPERTY_QUERY structure _In_ (DWORD) nInBufferSize, // size of input buffer _Out_opt_ (LPVOID) lpOutBuffer, // output buffer - see Remarks _In_ (DWORD) nOutBufferSize, // size of output buffer _Out_opt_ (LPDWORD) lpBytesReturned, // number of bytes returned _Inout_opt_ (LPOVERLAPPED) lpOverlapped ); // OVERLAPPED structure
A handle to the disk device from which partition information is retrieved. To retrieve a device handle, call the CreateFile function.
The control code for the operation. Use IOCTL_STORAGE_QUERY_PROPERTY for this operation.
A pointer to a buffer that contains a STORAGE_PROPERTY_QUERY data structure that specifies the details about the query. Device properties must be retrieved only from a device; attempting to retrieve device properties from an adapter will cause an error.
The size of the input buffer, in bytes. It must be large enough to contain a STORAGE_PROPERTY_QUERY data structure.
An optional pointer to a buffer that receives a structure that starts with the same fields as a STORAGE_DESCRIPTOR_HEADER data structure. For more information on the specific structures returned see the Remarks section.
The size of the output buffer, in bytes. It can be zero to determine whether a property exists without retrieving its data. To do that, set this parameter to zero (0) and the QueryType member of the STORAGE_PROPERTY_QUERY input structure to PropertyExistsQuery (1). If the call to DeviceIoControl returns a nonzero value then the property exists.
A pointer to a variable that receives the size of the data stored in the output buffer, in bytes.
If the output buffer is too small, the call fails, GetLastError returns ERROR_INSUFFICIENT_BUFFER, and lpBytesReturned is zero.
If lpOverlapped is NULL, lpBytesReturned cannot be NULL. Even when an operation returns no output data and lpOutBuffer is NULL, DeviceIoControl makes use of lpBytesReturned. After such an operation, the value of lpBytesReturned is meaningless.
If lpOverlapped is not NULL, lpBytesReturned can be NULL. If this parameter is not NULL and the operation returns data, lpBytesReturned is meaningless until the overlapped operation has completed. To retrieve the number of bytes returned, call GetOverlappedResult. If hDevice is associated with an I/O completion port, you can retrieve the number of bytes returned by calling GetQueuedCompletionStatus.
A pointer to an OVERLAPPED structure.
If hDevice was opened without specifying FILE_FLAG_OVERLAPPED, lpOverlapped is ignored.
If hDevice was opened with the FILE_FLAG_OVERLAPPED flag, the operation is performed as an overlapped (asynchronous) operation. In this case, lpOverlapped must point to a valid OVERLAPPED structure that contains a handle to an event object. Otherwise, the function fails in unpredictable ways.
For overlapped operations, DeviceIoControl returns immediately, and the event object is signaled when the operation is complete. Otherwise, the function does not return until the operation is complete or an error occurs.
If the operation completes successfully, DeviceIoControl returns a nonzero value.
The optional output buffer returned through the lpOutBuffer parameter can be one of several structures depending on the value of the PropertyId member of the STORAGE_PROPERTY_QUERY structure pointed to by the lpInBuffer parameter. These values are enumerated by the STORAGE_PROPERTY_ID enumeration. If the QueryType member of the STORAGE_PROPERTY_QUERY is set to PropertyExistsQuery then no structure is returned.
Minimum supported client
|Windows XP [desktop apps only]|
Minimum supported server
|Windows Server 2003 [desktop apps only]|