Does IOCTL_STORAGE_QUERY_PROPERTY work with dynamic disks? With the
following code, my DeviceIoControl() call returns successfully with basic
disks; however, it receives an ERROR_INVALID_PARAMETER (87) when accessing
dynamic disks. Any suggestions would be most welcome.
Cheers,
Steve
int DeviceType(WCHAR DriveLetter, STORAGE_BUS_TYPE *Type)
{
HANDLE fd;
WCHAR Path = L"\\.\c:";
STORAGE_PROPERTY_QUERY Property;
STORAGE_DEVICE_DESCRIPTOR Descriptor;
DWORD s;
Path[4] = DriveLetter;
fd = CreateFileW(Path, GENERIC_READ, 0,
NULL, OPEN_EXISTING, 0, NULL);
if (fd == INVALID_HANDLE_VALUE)
{
myError(L"Error opening device.", GetLastError());
return(-1);
}
Property.QueryType = PropertyStandardQuery;
Property.PropertyId = StorageDeviceProperty;
if (DeviceIoControl(fd, IOCTL_STORAGE_QUERY_PROPERTY,
&Property, sizeof(Property), &Descriptor, sizeof(Descriptor), &s,
NULL) == 0)
{
MyError(L"Error retrieving device type.", GetLastError());
CloseHandle(fd);
return(-1);
}
*Type = Descriptor.BusType;
CloseHandle(fd);
return(0);
}