Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Desktops (https://www.askmehelpdesk.com/forumdisplay.php?f=427)
-   -   IOCTL_STORAGE_QUERY_PROPERTY failing on non-boot hard drive? (https://www.askmehelpdesk.com/showthread.php?t=600885)

  • Oct 4, 2011, 09:28 AM
    sisakhar
    IOCTL_STORAGE_QUERY_PROPERTY failing on non-boot hard drive?
    Hi,
    I have C++ Code that query HD property of all drives connected to the system. The code sends IOCTL_STORAGE_QUERY_PROPERTY, with DeviceIOControl function. This code works great on Windows XP, however on Windows Server 2008 SP2 (64 bit), it fails with error code 87. I am able to read device properties from \\.\PhysicalDrive0 - boot drive, but not from any other drives. I have 3 hd connected, all SAS drives.

    Here is the code. Please help.

    HANDLE hdl=drive_handle;
    DWORD bytesRet;
    DWORD outSize;
    DWORD error;
    STORAGE_PROPERTY_QUERY input;
    STORAGE_DEVICE_DESCRIPTOR *output;

    Memset(&input, 0, sizeof(input));

    input.PropertyId = StorageDeviceProperty;
    input.QueryType = PropertyExistsQuery;

    if(!DeviceIoControl(hdl,
    IOCTL_STORAGE_QUERY_PROPERTY,
    &input,
    sizeof(STORAGE_PROPERTY_QUERY),
    NULL,
    0,
    &bytesRet,
    NULL))
    {
    error = GetLastError();
    tsVerbose(1,"Failed to storage property query, error %d", error);
    return FALSE;
    }

  • All times are GMT -7. The time now is 03:18 PM.