Thanks.
I also find some thing :
1)use drive letter, use createfile
2)use IOCTL_STORAGE_PROPERTY_QUERY, query some property of the
storage device
3)if device's Bustype is BusTypeUsb, it's based on usb device
4)vid & pid is obvious in out data
IOCTL_STORAGE_QUERY_PROPERTY Control Code
已有 78 次阅读
2011-04-26 16:30
- 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
-
- Parameters
-
- hDevice
-
- A handle to the disk device from which partition information is retrieved. To retrieve a device handle, call the CreateFile function.
- dwIoControlCode
-
- The control code for the operation. Use IOCTL_STORAGE_QUERY_PROPERTY for this operation.
- lpInBuffer
-
- 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.
- nInBufferSize
-
- The size of the input buffer, in bytes. It must be large enough to contain a STORAGE_PROPERTY_QUERY data structure.
- lpOutBuffer
-
- 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.
- nOutBufferSize
-
- 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.
- lpBytesReturned
-
- 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 s