How to Match Drive Letter to SCSI ID RRS feed

  • Question

  • We have converted a c++ application that accesses scsi jukebox and scsi optical drives with ASPI to use SPTI.  The application uses the SetupDi calls to find all of the scsi devices and their IDs.  It also calls GetLogicalDriveStrings and GetDriveType to get and display the drive letters assigned by the OS.  What I have not figured out is how to link the drive letters to the scsi ids.  I would like to do this automatically to prevent users from entering mismatched information into the application.

    Thursday, December 2, 2010 3:57 PM

All replies

  • Hi MesaCorp,

    Once you get DevicePathId (that could be scsi style path id), use GetVolumeNameForVolumeMountPoint to find out the volume name, and once you get the volume name you'll be able to get mounting points.

    Wednesday, December 15, 2010 1:50 AM
  • Thanks for your response but I believe I still have a problem.

    Maybe I'm missing something but GetVolumeNameForVolumeMountPoint wants a drive letter, e:\, string for input.  So I fed it the drive letters I've identified as belonging to a removable drive and it returns a volume GUID.  I still don't see how to link the volume GUID to the target id that I have already determined belong to a SCSI optical drive.

    Maybe this will be helpful.  I've listed below the primary calls that I am making and examples of the information that I have gathered from these calls.

     Get the device instance id

     Get the adapter id

     Get the device id

     Get the device path

    DeviceIoControl( hDevice, IOCTL_STORAGE_QUERY_PROPERTY
     Get bus type, max transfer length, max physical pages, and alignment mask

    DeviceIoControl( hDevice, IOCTL_SCSI_GET_INQUIRY_DATA
     Get the initiator bus id, path id, target id, lun, and device claimed

     determine the removable drive letters


    What I need to be able to do is link the target id, lun, and path id I have from the inquiry call to a specific removable drive letter.

    It appears that the first target id I find will link to the first drive letter I find but I'm leery of assuming that this will always be true.  I'm hoping there is a more concrete way to link target id to drive letter.


    Thursday, December 16, 2010 10:29 PM
  • It is possible to use device path id in GetVolumeNameForVolumeMountPoint method. In that case you'll get volume name for your CDROM device. Also please try with/without trailing backslash for the device path id.

    With Regards,

    Monday, December 20, 2010 8:28 PM